8.4.4 execute()
- Organization of this subsection
(1) Function
This method executes the preprocessed SQL statement.
You can use the getResultSet and getUpdateCount methods (or the getLargeUpdateCount method) of the PreparedStatement object to obtain the ResultSet object and the number of updated rows as execution results.
For the return values of the getResultSet method and getUpdateCount method (or getLargeUpdateCount method) after execution of the execute method, see Table 8‒8: Return values of the getResultSet and getUpdateCount methods (or the getLargeUpdateCount method) depending on the type of the SQL statement that was executed.
(2) Format
public synchronized boolean execute() throws SQLException
(3) Arguments
None.
(4) Return value
If a retrieval SQL statement was executed, this method returns true; if not, the method returns false.
(5) Exceptions
The JDBC driver throws an SQLException in the following cases:
-
The PreparedStatement object is closed.
-
The Connection object that created this PreparedStatement object is closed.
-
No value is set in at least one dynamic parameter.
-
A database access error occurs.