SQL statement execution: Statement, preparestatement, and callablestatement

Source: Internet
Author: User

The three methods in the connection interface can be used to create instances of these classes. These classes and their creation methods are listed below:

(1) Statement-created by the createstatement method. The statement object is used to send simple SQL statements.
(2) preparedstatement-created by the preparestatement method.
(3) The preparedstatement object is used to send an SQL statement with one or more input parameters (in parameters. Preparedstatement has a set of methods used to set the value of the in parameter.

When a statement is executed, these in parameters are sent to the database. Preparedstatement instances extend the statement, so they all include the statement method.

The preparedstatement object may be more efficient than the statement object because it has been precompiled and stored there for future use.

Callablestatement-created by the preparecall method. Callablestatement object is used to execute SQL StorageProgram-A group of SQL statements that can be called by name (just like a function call. The callablestatement object inherits the methods used to process the in parameter from the preparedstatement object, and also adds methods used to process the out and inout parameters.

The methods listed below can quickly decide which connection method to apply to create different types of SQL statements:

The createstatement method is used for simple SQL statements (without parameters ).

The preparestatement method is used to execute simple SQL statements that contain one or more in parameters.

The preparecall method is used to call the stored procedure.

 

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.