8.3.13 executeUpdate(String sql)
- Organization of this subsection
(1) Function
This method executes a 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(String sql) method instead of the executeUpdate(String sql) method. If you use the executeUpdate(String sql) method, it will return 0 if the number of updated rows exceeds Integer.MAX_VALUE.
(2) Format
public synchronized int executeUpdate(String sql) throws SQLException
(3) Arguments
- String sql
-
Specifies the SQL statement (non-retrieval SQL statement) that is to be executed.
(4) Return value
If an INSERT, UPDATE, or DELETE statement was executed, this 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 Statement object is closed.
-
The Connection object that created the Statement object is closed.
-
A retrieval SQL statement (SELECT statement) was executed.
-
null or a character string with a length of zero was specified in the sql argument.
-
A database access error occurs.
-
The specified SQL statement exceeds 16,000,000 characters.