头痛了两天的问题终于得到解决了,特此写下(原创):
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
int i = stmt.executeUpdate("insert into TESTTWO values(4,Empty_BLOB(),'/dqpisei/')");
ResultSet rs = stmt.executeQuery("select BLOB from TESTTWO where ID = 4 for update");
if(rs.next()){
oracle.sql.BLOB blob = (BLOB)rs.getBlob("BLOB");
PrintStream ps = new PrintStream(blob.getBinaryOutputStream());
File file = new File("H:\\film\\移动互联网的关键技术IPv6.pdf");
// File file = new File("F:\\课程论文.doc");
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
file));
byte[] buff = new byte[1024];
int n = 0;
while ( (n = bis.read(buff)) != -1) {
ps.write(buff, 0, n);
}
ps.flush();
ps.close();
bis.close();
}
rs.close();
stmt.close();
conn.close();
System.out.println( " i : " + i);