Oracle pre-compiled SQL statement processing in JDBC

Source: Internet
Author: User

I. Pre-compiled SQL statement Processing

Precompilation interface PreparedStatement is an interface in java. SQL, which is a self-interface of Statement. Statement sends the complete SQL Statement to the database after being compiled. The pre-compiled Statement is different from the Statement object. An SQL Statement is specified when the PreparedStatement object is created. The SQL Statement is immediately sent to the database for compilation. When a compiled statement is executed, the compiled SQL statement is directly run, unlike other SQL statements that are compiled and executed first. The processing performance of pre-compiled SQL statements is slightly higher than that of common variables.

2. encapsulation of web Project Persistence Layer

Understand Oracle dynamic parameter binding. Using the Oracle placeholder: the statement is directly cached by using the sharing pool in SGA. Then, when executing a similar statement in the next time, the resolved statement in the cache is called directly, to improve the execution efficiency.

Now there are a lot of persistence layer frameworks, I personally like, or like the most primitive SQL method, if a programmer does not write SQL, then he is not a programmer.

For the explanations of the SQL pre-compilation and Oracle cache mechanisms, you may have thought that using PreparedStatement can improve the SQL Execution efficiency,? The placeholder cannot be cached in SGA. The next time you execute the DAO method, It will be precompiled. Therefore, the SQL statement with the placeholder is passed as a parameter to the PreparedStatement and cached in SGA, this further improves the development efficiency of the persistent layer.

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.