加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 14:49:32 所属栏目:百科 来源:网络整理
导读: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
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:UsersZugantanDesktop附件章模板.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(); } }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读