/**
 * 更新数据库的Blob字段。(sqlStr = update tableName set blobField=? where ...)
 *  @param String tableName 表名
 *  @param String blobField blob字段名
 *  @param byte[] blob 更新后blobField的内容
 *  @param String strPK where 后面的条件,这里是主键字符串
 *  @return void 返回空
 */    
   
     public void updateBlob(String tableName, String blobField, String strPK, byte[] blob) throws Exception
{ if (conn == null)
throw new SQLException("database connection is not availble!");
boolean oldcommit=conn.getAutoCommit();
String strSQLUpdate= "update " + tableName + " set " + blobField + "=EMPTY_BLOB() where " + strPK;
String strSQL= " select " + blobField + " from " + tableName + " where " + strPK + " for update";
try
{
conn.setAutoCommit(false);
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)
{
conn.rollback();
throw e;
}
finally
{
conn.setAutoCommit(oldcommit);
}
}