简体   繁体   English

Teradata CLOB和JDBC:定位器无效,因为它已更改错误

[英]Teradata CLOB and JDBC : The Locator is invalid because it has been changed ERROR

I'm trying to copy CLOB from one database to another. 我正在尝试将CLOB从一个数据库复制到另一个数据库。 However I get The Locator is invalid because it has been changed error. 但是我得到了The Locator is invalid because it has been changed错误。

This article says this can happen because ResultSet , PreparedStamenent are closed. 本文说,由于ResultSetPreparedStamenent已关闭,因此会发生这种情况。 However all my objects are open. 但是我所有的对象都是打开的。 And the error is thrown when I try to executeBatch() 当我尝试执行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

Why does this happen? 为什么会这样? How to prevent this? 如何预防呢?


PS: The above code runs well with any other data type: VARCHAR, DECIMAL PS:上面的代码可以与任何其他数据类型一起很好地运行:VARCHAR,DECIMAL

The article says that the CLOB is a locator that is valid in the same session. 文章说,CLOB是在同一会话中有效的定位器。

But when you try to apply it to another connection, you are using it in a different session, so the error occurs. 但是,当您尝试将其应用到另一个连接时,您正在其他会话中使用它,因此会发生错误。

What you need to do is to read the actual CLOB content from the source database and write it into the target database. 您需要做的是从源数据库读取实际的CLOB内容,并将其写入目标数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM