婢幣JDBC贋函寄侏方象斤?LOB秤趨議幣袈窃 - 園殻秘壇利
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-18
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL"); /* 序佩顕固塀俐個 */ BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream()); BufferedReader in = new BufferedReader(new FileReader(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); } /** * 紋算CLOB斤??繍圻CLOB斤?賠茅?算撹匯倖畠仟議CLOB斤?? * * @param infile - 方象猟周 * @throws java.lang.Exception * @roseuid 3EDA04BF01E1 */ public static void clobReplace(String infile) throws Exception { /* 譜協音徭強戻住 */ boolean defaultCommit = conn.getAutoCommit(); conn.setAutoCommit(false); try { /* 賠**圻CLOB斤? */ stmt.executeUpdate("UPDATE TEST_CLOB SET CLOBCOL=EMPTY_CLOB() WHERE ID=''''111''''"); /* 臥儂CLOB斤?旺迄協 */ ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE ID=''''111'''' FOR UPDATE"); while (rs.next()) { /* 資函緩CLOB斤? */ oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL"); /* 厚仟方象 */ BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream()); BufferedReader in = new BufferedReader(new FileReader(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); } /** * CLOB斤?響函 * * @param outfile - 補竃猟周兆 * @throws java.lang.Exception * @roseuid 3EDA04D80116 */ public static void clobRead(String outfile) throws Exception { /* 譜協音徭強戻住 */ boolean defaultCommit = conn.getAutoCommit(); conn.setAutoCommit(false); try { /* 臥儂CLOB斤? */ ResultSet rs = stmt.executeQuery("SELECT * FROM TEST_CLOB WHERE ID=''''111''''"); while (rs.next()) { /* 資函CLOB斤? */ oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL"); /* 參忖憲侘塀補竃 */ BufferedReader in = new BufferedReader(clob.getCharacterStream()); |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于婢幣JDBC贋函寄侏方象斤?LOB秤趨議幣袈窃 - 園殻秘壇利的所有评论