【发布时间】:2017-03-10 14:13:04
【问题描述】:
我正在尝试将CLOB 从一个数据库复制到另一个数据库。但是我得到The Locator is invalid because it has been changed 错误。
article 表示这可能会发生,因为 ResultSet、PreparedStamenent 已关闭。但是我所有的对象都是打开的。当我尝试executeBatch()时抛出错误
Statement select = connectionDB1.createStatement();
ResultSet rs = select.executeQuery("SELECT TOP 1 myClob FROM myTab");
rs.next();
PreparedStatement ps = connectionDB2.prepareStatement("INSERT INTO myTab2 SELECT ? ");
ps.setClob(1, rs.getClob(1));
System.out.println("CLOB inserted");
ps.addBatch();
ps.executeBatch(); // ERROR is thrown here before I close any objects WHY?
// java.sql.BatchUpdateException
为什么会这样?如何预防?
PS:上面的代码可以很好地与任何其他数据类型一起运行:VARCHAR、DECIMAL
【问题讨论】: