|
Home > Archive > PostgreSQL JDBC > December 2005 > java.sql.BatchUpdateException
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
java.sql.BatchUpdateException
|
|
| Averbukh Stella 2005-12-21, 8:25 pm |
| 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, 2004120905571
5, 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/pgsq...08/msg00461.php
I will appreciate if anybody can help me with this issue.
Snapshot of my source code:
++++++++++++++++++++
++++++++++++++++++++
++++++++
public void storeIntervals(Itera
tor 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(ins
ertQuery);
updateStmt = connection. prepareStatement(upd
ateQuery);
while (iterator.hasNext())
{
CafMotionInterval mi = (CafMotionInterval) iterator.next();
updateEarliestProces
sedStartUtc(mi);
touchedPanelists.add(mi.getPanelistId());
reconcileAccum.min(mi.getPanelistId(), mi.getStartUtc());
if (mi.getKey() == null)
{
_addBatchInsertCafMo
tionInterval(insertS
tmt, mi);
insertBatchManager. addBatch(insertStmt)
;
}
else
{
_addBatchUpdateCafMo
tionInterval(updateS
tmt, mi);
updateBatchManager. addBatch(updateStmt)
;
}
}
updateStmt.executeBatch();
insertStmt.executeBatch();
}
catch (SQLException e)
{
throw new CtFatalException("Failure in storeCafMotionIterva
ls", e. getNextException());
}
finally
{
JdbcUtility.close(insertStmt);
JdbcUtility.close(updateStmt);
}
}
In JdbcBatchManager:
public void addBatch(PreparedSta
tement pStmt)
throws SQLException
{
if (maxUnexecutedCount <= unexecutedCount)
{
pStmt.executeBatch();
unexecutedCount = 0;
}
unexecutedCount++;
pStmt.addBatch();
}
++++++++++++++++++++
++++++++++++++++++++
+++++++++
Thank you.
Stella.
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
| |
| Kris Jurka 2005-12-21, 8:25 pm |
|
On Wed, 21 Dec 2005, Averbukh Stella wrote:
> 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.;
>
This error message only tells you that an error has occurred. As it
suggests, you must call getNextException to see the underlying problem.
Kris Jurka
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly
|
|
|
|
|