java输出流怎么转化为java.sql.blob

   导出excel的时候

OutputStream 转化为blob类型传给前端

|

if (conn == null)

throw new SQLException("database connection is not availble!");

String strSQLUpdate= "update demo set blobTest =EMPTY_BLOB() where id=1";

String strSQL= " select blobTest from demo where id=1 for update";

try

{
PreparedStatement tmpstmt=conn.prepareStatement(strSQLUpdate);

tmpstmt.executeUpdate();

tmpstmt=conn.prepareStatement(strSQL);

ResultSet tmprlt=tmpstmt.executeQuery();

while (tmprlt.next())

{
java.sql.Blob javaBlob = tmprlt.getBlob(blobField);

oracle.sql.BLOB tmpblob = (oracle.sql.BLOB)javaBlob;

OutputStream os= tmpblob.getBinaryOutputStream();

if(blob != null)

os.write(blob);

os.close();

}

if (oldcommit==true)

{
conn.commit();

}

}

catch(Exception e)

{
throw e;

}

finally

{
}