Preparestatement has two executequery Methods: one with parameters and the other without parameters.
Executequery with parameters:
Resultset executequery (string SQL) throws sqlexception
Executes the given SQL statement, which returns a single
Resultset
Object.
Note:This method cannot be called onPreparedstatement
OrCallablestatement
.
-
- Parameters:
-
-
SQL
-An SQL statement to be sent to the database,
Typically a static SQLSelect
Statement
-
- Returns:
-
-
A
Resultset
Object that contains the data produced by the given query; never
Null
-
- Throws:
-
-
Sqlexception
-If a database access error occurs, this method is called on a closed
Statement
, The given SQL statement produces anything other than a single
Resultset
Object, the method is called on
Preparedstatement
Or
Callablestatement
-
-
Sqltimeoutexception
-When the driver has determined that the timeout value that was specified by
Setquerytimeout
Method has been exceeded and has at least attempted to cancel the currently running
Statement
That is to say, if the executequery (SQL) method is used, the SQL statement in the parameter must be static. That is, there cannot be "?" Replace the parameters in the statement.
Executequery without parameters:
Resultset executequery () throws sqlexception
Executes the SQL query in this
Preparedstatement
Object and returns
Resultset
Object generated by the query.
- Returns:
-
A
Resultset
Object that contains the data produced by the query; never
Null
- Throws:
-
Sqlexception
-If a database access error occurs; this method is called on a closed
Preparedstatement
Or the SQL statement does not return
Resultset
Object
-
Sqltimeoutexception
-When the driver has determined that the timeout value that was specified by
Setquerytimeout
Method has been exceeded and has at least attempted to cancel the currently running
Statement