日期:2014-05-20 浏览次数:20657 次
Connection con = ... int[] data = ... PreparedStatement stmt= con.prepareStatement("insert into t_test(array_field) values(?)"); stmt.setObject(1, data,java.sql.Types.BINARY); stmt.execute();
------解决方案--------------------
正好项目有,就给你一个读取的代码吧.不能完全相同,你自己改一下吧:
FileOutputStream out = null; InputStream in = null; //SQL语句我就不写了,就是select那个字段 try { if(rs.next()) { out = new FileOutputStream("C:\a.jpg"); in = rs.getBinaryStream("image1"); byte b[] = new byte[0x7a120]; for (int i = in.read(b); i != -1;) { out.write(b); i = in.read(b); } } } catch (Exception e) { System.out.println(e); }