婢幣JDBC贋函寄侏方象斤?LOB秤趨議幣袈窃 - 園殻秘壇利
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-18
BufferedWriter out = new BufferedWriter(new FileWriter(outfile)); int c; while ((c=in.read())!=-1) { out.write(c); } out.close(); in.close(); } } catch (Exception ex) { conn.rollback(); throw ex; } /* 志鹸圻戻住彜蓑 */ conn.setAutoCommit(defaultCommit); } /** * ?方象垂嶄峨秘匯倖仟議BLOB斤? * * @param infile - 方象猟周 * @throws java.lang.Exception * @roseuid 3EDA04E300F6 */ public static void blobInsert(String infile) throws Exception { /* 譜協音徭強戻住 */ boolean defaultCommit = conn.getAutoCommit(); conn.setAutoCommit(false); try { /* 峨秘匯倖腎議BLOB斤? */ stmt.executeUpdate("INSERT INTO TEST_BLOB VALUES (''''222'''', EMPTY_BLOB())"); /* 臥儂緩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斤??頁壓圻BLOB斤?児粥貧序佩顕固塀議俐個? * * @param infile - 方象猟周 * @throws java.lang.Exception * @roseuid 3EDA04E90106 */ public static void blobModify(String infile) throws Exception { /* 譜協音徭強戻住 */ boolean defaultCommit = conn.getAutoCommit(); conn.setAutoCommit(false); try { /* 臥儂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); } |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于婢幣JDBC贋函寄侏方象斤?LOB秤趨議幣袈窃 - 園殻秘壇利的所有评论