What does this BatchUpdateException mean?
Asked Answered
C

3

6

I'm getting this BatchUpdateException from a stmt.executeBatch() statement:

BatchUpdateException: A resultset was created for update

The internet does not have any information on this exception message. What does it mean? The traceback doesn't contain anything useful other than that a stored procedure failed.

Christo answered 15/3, 2011 at 8:5 Comment(0)
G
12

I'd interpret the message as meaning that an SQL statement that you added via addBatch() has produced a ResultSet, meaning that it's not your normal INSERT, UPDATE or DELETE statement.

Statements that should return results can't be executed in batches with JDBC.

The JDBC Tutorial (under the heading "Handling Batch Update Exceptions") confirms it:

You will get a BatchUpdateException when you call the method executeBatch if (1) one of the SQL statements you added to the batch produces a result set (usually a query) or (2) one of the SQL statements in the batch does not execute successfully for some other reason.

You seem to be running into case 1 here.

Gregorygregrory answered 15/3, 2011 at 8:34 Comment(0)
T
1

A batch-update are several insert/update/delete statements which are processed by the database together. This is usualy done for perfomance reasons. 1x 1000 inserts is much faster than 1000x 1 insert. A BatchUpdateException means 1 (or more) statements failed most often due to a constraint-violation. You will have to look at the stored procedure to see what it has been doing. Mayby your dba can give you more information about what went wrong.

Tedda answered 15/3, 2011 at 8:35 Comment(1)
This is one reason for a BatchUpdateException, he seems to be seeing the other one (see my answer).Gregorygregrory
C
0

I dropped one column from the table. When i tried to insert records to that table i was getting BatchUpdateException.

After running the below command the problem got solved

REORG TABLE TABLE_NAME

Cornelison answered 3/7, 2014 at 11:44 Comment(1)
this does not really asnwers the questions as it was: "What does BatchUpdateException mean?"Fabrizio

© 2022 - 2024 — McMap. All rights reserved.