- 0
- 0
- 约5.64千字
- 约 5页
- 2018-05-22 发布于河南
- 举报
jdbc处理blob对象编程源代码
设有表:create?table?blobimg?(id?int?primary?key,?contents?blob);一、BLOB入库的专用访问:????1)?最常见于Oracle的JDBC示例中????一般是先通过select??...?for?update锁定blob列,然后写入blob值,然后提交。要用到特定的Oracle?BLOB类。?
Class.forName(oracle.jdbc.driver.OracleDriver);
Connection?con?=?DriverManager.getConnection(jdbc:oracle:thin:@localhost:1521:testdb,?test,?test);
//处理事务
con.setAutoCommit(false);
Statement?st?=?con.createStatement();
//插入一个空对象
st.executeUpdate(insert?into?BLOBIMG??values(1,empty_blob()));
//用for?update方式锁定数据行
ResultSet?rs?=?st.executeQuery(
??????????select?contents?from??BLOBIMG??where??id=1??for?update);
if?(rs.ne
原创力文档

文档评论(0)