向oracle表的BLOB字段插入图片的方法

前端之家收集整理的这篇文章主要介绍了向oracle表的BLOB字段插入图片的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
package jdbc.day01; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.sqlException; /** * * * 将附件章插入数据库表*/ public class BolbTest { public static void main(String[] args) throws FileNotFoundException,sqlException { File file = new File("C:\\Users\\Zugantan\\Desktop\\附件章模板.img"); int len =(int)file.length(); InputStream inStream = new FileInputStream(file); Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@10.20.188.82:1521:orcl","sunyard","sunyard"); /*将附件章插入数据库表*/ PreparedStatement ps = conn.prepareStatement("insert into sm_page_seal_tb(sealimage) values (?)" ); ps.setBinaryStream(1,inStream,len); boolean flag = ps.execute(); if(flag==true){ //成功 System.out.println("BLOB............."); }else{ System.out.println("fail...."); } conn.commit(); ps.close(); conn.close(); } } 原文链接:https://www.f2er.com/oracle/208880.html

猜你在找的Oracle相关文章