2

我正在使用以下代码将数据插入表中。

test_conn.setAutoCommit(false);
stmt = test_conn.prepareStatement("INSERT INTO ...");

while(RSet.next()){
   for(int i = 1; i <= columnCount; i++){
       stmt.setString(i, RSet.getString(i));
   }
   stmt.addBatch();
}

stmt.executeBatch();
test_conn.commit();

其他处理方法只发生以上所有行都成功插入....

当我使用 Insert 插入表时executeBatch(),如果 Inserting 发生 SQL Exception 或 Error ,是否有可能找到哪个 Record 的 Insertion 引发了异常?

4

1 回答 1

0

您必须致电并检查异常中的详细信息try-catchstmt.executeBatch()批处理执行将在将发生的第一个错误时停止。

于 2015-03-18T10:35:56.833 回答