String sql = "INSERT INTO T_PARTI_PRT_CONFIGFILE(CODE,CONTENT) VALUES(?,EMPTY_BLOB())";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, "a");
pst.execute();
String sqll = "SELECT CONTENT FROM T_PARTI_PRT_CONFIGFILE WHERE CODE=? FOR UPDATE";
pst.setString(1, "a");
ResultSet rs = pst.executeQuery(sqll);
if (rs.next()) {
Blob mapBlob = rs.getBlob("CONTENT");
   OutputStream blobOutputStream = ((oracle.sql.BLOB)mapBlob).getBinaryOutputStream(); File mapFile = new File("D:/test/crtfilterrules.xml");
InputStream sampleFileStream = new FileInputStream(mapFile);
byte[] buffer = new byte[10 * 1024];
int nread = 0;
// Number of bytes read
while ((nread = sampleFileStream.read(buffer)) != -1)
// Read from file
blobOutputStream.write(buffer, 0, nread);
// Write to Blob Close both streams
sampleFileStream.close();
blobOutputStream.close(); }
好像 content(Blob类型)的内容始终为空,这是为什么啊?
其中 OutputStream blobOutputStream = ((oracle.sql.BLOB)mapBlob).getBinaryOutputStream();
别划线了,提示:The method getBinaryOutputStream() from the type BLOB is deprecated
是什么意思?