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.