Question & Answer
Question
The JDBC executeUpdate method can return a negative row count when the database server is DB2 for z/OS.
Cause
The JDBC standard states that the executeUpdate method returns a row count or 0. However, if the executeUpdate method is executed against a DB2® for z/OS® server, it can return a value of -1.
Answer
For executeUpdate statements against a DB2 for z/OS server, the value that is returned depends on the type of SQL statement that is being executed:
- For an SQL statement that can have an update count, such as an INSERT, UPDATE, or DELETE statement, the returned value is the number of affected rows. It can be:
- A positive number, if a positive number of rows are affected by the operation, and the operation is not a mass delete on a segmented table space.
- 0, if no rows are affected by the operation.
- -1, if the operation is a mass delete on a segmented table space.
- For a DB2 CALL statement, a value of -1 is returned, because the DB2 database server cannot determine the number of affected rows. Calls to getUpdateCount or getMoreResults for a CALL statement also return -1.
- For any other SQL statement, a value of -1 is returned.
[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEPEK","label":"Db2 for z\/OS"},"Component":"SQLJ\/JDBC","Platform":[{"code":"PF025","label":"Platform Independent"},{"code":"PF035","label":"z\/OS"}],"Version":"All Versions","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Was this topic helpful?
Document Information
Modified date:
20 June 2019
UID
swg21244002