From: | "Averbukh Stella" <Stella(dot)Averbukh(at)arbitron(dot)com> |
---|---|
To: | <pgsql-jdbc(at)postgresql(dot)org> |
Cc: | "Averbukh Stella" <Stella(dot)Averbukh(at)arbitron(dot)com> |
Subject: | java.sql.BatchUpdateException |
Date: | 2005-12-21 19:20:54 |
Message-ID: | C9995BA6EBD30240A86235B6FCCF5A680E010679@ARBEX2KC.arbitron.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2005-12-21 21:02:42 | Re: java.sql.BatchUpdateException |
Previous Message | Oliver Jowett | 2005-12-21 12:41:30 | Re: Bug: Driver(8.2dev-500.jdbc3) does not handle |