Two executequery statements of preparestatement

Source: Internet
Author: User

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 onPreparedstatementOrCallablestatement.

Parameters:
SQL-An SQL statement to be sent to the database, Typically a static SQLSelectStatement
Returns:
A ResultsetObject 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 ResultsetObject, the method is called on PreparedstatementOr Callablestatement
Sqltimeoutexception-When the driver has determined that the timeout value that was specified by SetquerytimeoutMethod 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 ResultsetObject 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 PreparedstatementOr the SQL statement does not return ResultsetObject
Sqltimeoutexception-When the driver has determined that the timeout value that was specified by SetquerytimeoutMethod has been exceeded and has at least attempted to cancel the currently running Statement

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.