日期:2014-05-16 浏览次数:20557 次
Connection connection = getConnection(); connection.setAutoCommit(false); PreparedStatement?statement = connection.prepareStatement("select sql_txt from table where id = ? for update"); //在这里的字段类型是clob,而且这个方法注意的是这个查询出来的字段一定不能是null对象或者零长度字符串 //还有一点需要注意的是oracle中这个方法必须带有for update这部分的语句,不然会出现这个异常 //java.io.IOException: ORA-22920: row containing the LOB value is not locked statement.setString(1, uuid); rs = statement.executeQuery(); if(rs.next()) { ? ? CLOB clob = (CLOB)rs.getClob(1); ? ? BufferedWriter writer = new BufferedWriter(clob.getCharacterOutputStream()); ? ? writer.write(SQL_TXT); ? ? writer.flush(); ? ? writer.close(); } else { ? ? connection.rollback(); }