8.4.7 executeUpdate()
- Organization of this subsection
(1) Function
This method executes a preprocessed SQL statement (other than a retrieval SQL statement) and returns the number of updated rows as int data.
If the number of updated rows might exceed Integer.MAX_VALUE, use the executeLargeUpdate() method instead of the executeUpdate() method. If you use the executeUpdate() method, it will return 0 if the number of updated rows exceeds Integer.MAX_VALUE.
(2) Format
public synchronized int executeUpdate() throws SQLException
(3) Arguments
None.
(4) Return value
If an INSERT, UPDATE, or DELETE statement was executed, the method returns the number of updated rows as int data. If any other SQL statement was executed, the method returns 0.
(5) Exceptions
The JDBC driver throws an SQLException in the following cases:
-
The PreparedStatement object is closed.
-
The Connection object that created this object is closed.
-
A retrieval SQL statement was executed.
-
No value is set in at least one dynamic parameter.
-
A database access error occurs.