8.3.29 getUpdateCount()
- Organization of this subsection
(1) Function
This method returns the number of updated rows as int data.
If the number of updated rows might exceed Integer.MAX_VALUE, use the getLargeUpdateCount method instead of the getUpdateCountmethod. If you use the getUpdateCount method, 0 is returned if Integer.MAX_VALUE is exceeded.
(2) Format
public synchronized int getUpdateCount() throws SQLException
(3) Arguments
None.
(4) Return value
The following table describes the details of the return value.
|
Statement object's method execution status |
Return value of getUpdateCount or getLargeUpdateCount method |
|||
|---|---|---|---|---|
|
No executeXXX method has been executed. |
-1 |
|||
|
An executeXXX method has been executed. |
A getMoreResults method was executed after the last executeXXX method was executed. |
-1 |
||
|
The last executeXXX method executed resulted in an error. |
-1 |
|||
|
The last method to be executed was an executeBatch or executeLargeBatch method |
-1 |
|||
|
The last method to be executed was an executeXXX method other than an executeBatch method or executeLargeBatch method |
A retrieval SQL statement was executed at the end. |
-1 |
||
|
A non-retrieval SQL statement was executed at the end. |
INSERT, UPDATE, DELETE |
Number of updated rows# |
||
|
Other |
0 |
|||
- #
-
If the number of updated rows might exceed Integer.MAX_VALUE, use the getLargeUpdateCount method instead of the getUpdateCount method. If you use the getUpdateCount method, it returns 0 if Integer.MAX_VALUE is exceeded.
(5) Exceptions
The JDBC driver throws an SQLException in the following cases:
-
The Statement object is closed.
-
The Connection object that created the Statement object is closed.