java.sql.BatchUpdateException - Mailing list pgsql-jdbc
From | Averbukh Stella |
---|---|
Subject | java.sql.BatchUpdateException |
Date | |
Msg-id | C9995BA6EBD30240A86235B6FCCF5A680E010679@ARBEX2KC.arbitron.com Whole thread Raw |
Responses |
Re: java.sql.BatchUpdateException
(Kris Jurka <books@ejurka.com>)
|
List | pgsql-jdbc |
Hello, I'm using postgresql-8.1-404.jdbc3.jar driver with the postgreSQL 8.1.0 server. I run the same source code that successfully executes under Oracle and hsqldb. However, when I run it under postgresql,I get following error: nested exception is: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO test_stream (id, code, start_utc, end_utc,start_local, end_local, tz_code, update_session) VALUES (302432-1, DOCK, 20041209100000, 20041209115715, 20041209040000,20041209055715, SD, 20051221_21) was aborted. Call getNextException to see the cause.; I found one reference to the similar error but it seemed from a long time ago and driver's source code didn't reflect it. http://archives.postgresql.org/pgsql-patches/2001-08/msg00461.php I will appreciate if anybody can help me with this issue. Snapshot of my source code: ++++++++++++++++++++++++++++++++++++++++++++++++ public void storeIntervals(Iterator iterator) throws CtFatalException { String insertQuery = "INSERT INTO test_stream (id, code, start_utc, end_utc, " + "start_local, end_local, tz_code, update_session) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; String updateQuery = "UPDATE test_stream SET id = ?, code = ?, " + "start_utc = ?, end_utc = ?, start_local = ?, end_local = ?, tz_code = ?, " + "update_session = ? WHERE motion_gnmbr = ?"; JdbcBatchManager insertBatchManager = new JdbcBatchManager(); JdbcBatchManager updateBatchManager = new JdbcBatchManager(); PreparedStatement insertStmt = null; PreparedStatement updateStmt = null; try { insertStmt = connection.prepareStatement(insertQuery); updateStmt = connection.prepareStatement(updateQuery); while (iterator.hasNext()) { CafMotionInterval mi = (CafMotionInterval) iterator.next(); updateEarliestProcessedStartUtc(mi); touchedPanelists.add(mi.getPanelistId()); reconcileAccum.min(mi.getPanelistId(), mi.getStartUtc()); if (mi.getKey() == null) { _addBatchInsertCafMotionInterval(insertStmt, mi); insertBatchManager.addBatch(insertStmt); } else { _addBatchUpdateCafMotionInterval(updateStmt, mi); updateBatchManager.addBatch(updateStmt); } } updateStmt.executeBatch(); insertStmt.executeBatch(); } catch (SQLException e) { throw new CtFatalException("Failure in storeCafMotionItervals", e.getNextException()); } finally { JdbcUtility.close(insertStmt); JdbcUtility.close(updateStmt); } } In JdbcBatchManager: public void addBatch(PreparedStatement pStmt) throws SQLException { if (maxUnexecutedCount <= unexecutedCount) { pStmt.executeBatch(); unexecutedCount = 0; } unexecutedCount++; pStmt.addBatch(); } +++++++++++++++++++++++++++++++++++++++++++++++++ Thank you. Stella.
pgsql-jdbc by date: