使用java程序update oracle 中 blob 字段

来源:互联网 发布:网络传销的基本特点是 编辑:程序博客网 时间:2024/06/04 18:04
String sql1 = "select f.editor_xml exml from t_sys_flow_info f where f.id in ("+infoId+") for update"; 

     
public void replaceXmlBySql(String sql,String fildName) throws SQLException, IOException {
Connection conn = this.getConnection();
ResultSet rs = null;
Statement st = conn.createStatement();
rs = st.executeQuery(sql);
oracle.sql.BLOB blob = null;
while (rs.next()) {
blob = (oracle.sql.BLOB) rs.getBlob(fildName);
OutputStream outStream = blob.getBinaryOutputStream();
//得到原有的xml的String类型数据
String data = this.ConvertBLOBtoString(blob);
if(data.indexOf("backWrite")==-1){
data = data.replaceAll(",close'", ",backWrite,close'");
byte[] newData = data.getBytes(); 
outStream.write(newData, 0, newData.length);
}
outStream.flush();
outStream.close();
}
conn.commit();
conn.close();
st.close();
rs.close();
}
0 0