婢幣JDBC贋函寄侏方象斤?LOB秤趨議幣袈窃 - 園殻秘壇利
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-18
in.close(); out.close(); } /* 屎塀戻住 */ conn.commit(); } catch (Exception ex) { /* 竃危指獄 */ conn.rollback(); throw ex; } /* 志鹸圻戻住彜蓑 */ conn.setAutoCommit(defaultCommit); } /** * 紋算BLOB斤??繍圻BLOB斤?賠茅?算撹匯倖畠仟議BLOB斤?? * * @param infile - 方象猟周 * @throws java.lang.Exception * @roseuid 3EDA0505000C */ public static void blobReplace(String infile) throws Exception { /* 譜協音徭強戻住 */ boolean defaultCommit = conn.getAutoCommit(); conn.setAutoCommit(false); try { /* 賠腎圻BLOB斤? */ stmt.executeUpdate("UPDATE TEST_BLOB SET BLOBCOL=EMPTY_BLOB() WHERE ID=''''222''''"); /* 臥儂緩BLOB斤?旺迄協 */ ResultSet rs = stmt.executeQuery("SELECT BLOBCOL FROM TEST_BLOB WHERE ID=''''222'''' FOR UPDATE"); while (rs.next()) { /* 函竃緩BLOB斤? */ oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob("BLOBCOL"); /* ?BLOB斤?嶄亟秘方象 */ BufferedOutputStream out = new BufferedOutputStream(blob.getBinaryOutputStream()); BufferedInputStream in = new BufferedInputStream(new FileInputStream(infile)); int c; while ((c=in.read())!=-1) { out.write(c); } in.close(); out.close(); } /* 屎塀戻住 */ conn.commit(); } catch (Exception ex) { /* 竃危指獄 */ conn.rollback(); throw ex; } /* 志鹸圻戻住彜蓑 */ conn.setAutoCommit(defaultCommit); } /** * BLOB斤?響函 * * @param outfile - 補竃猟周兆 * @throws java.lang.Exception * @roseuid 3EDA050B003B */ public static void blobRead(String outfile) throws Exception { /* 譜協音徭強戻住 */ boolean defaultCommit = conn.getAutoCommit(); conn.setAutoCommit(false); try { /* 臥儂BLOB斤? */ ResultSet rs = stmt.executeQuery("SELECT BLOBCOL FROM TEST_BLOB WHERE ID=''''222''''"); while (rs.next()) { /* 函竃緩BLOB斤? */ oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob("BLOBCOL"); /* 參屈序崙侘塀補竃 */ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outfile)); BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream()); int c; while ((c=in.read())!=-1) { out.write(c); } in.close(); out.close(); } /* 屎塀戻住 */ conn.commit(); } catch (Excepti |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于婢幣JDBC贋函寄侏方象斤?LOB秤趨議幣袈窃 - 園殻秘壇利的所有评论