Implementation of spring-database operation component

Source: Internet
Author: User

Ok, today read the Spring database component implementation of the source code, briefly take notes.

The first is the jdbctemplate, in fact, the implementation of this technology is very simple, is a template class, the execution of the backbone of the SQL process is written, such as connection acquisition, closure, abnormal capture, statement generation and so on, and the different parts of the exposure, Let the user customize, such as what statement do, the results to avabean mapping and so on.

Then there is the RDBMS, the bottom of which is also used JdbcTemplate. The functionality provided here is, I think, a way to provide an OO-oriented and reusable operation. The implementation is also very simple, save the SQL statement in the object, each time in execution, call the underlying jdbctemplate, the user passed in the parameters set to Preparestetement.

About connection and Preparestatement, looking at the bottom of the code, the implementation of JDBC, connection is to create a preparestatement cache, key is a question mark of the SQL statement, Because Preparestatement is more expensive to create than statement, caching is done here to reduce consumption. If the connection is turned off, its preparestatement will be lost, so look at the connection to close the time, actually did not really close, but to return it to the datasource.

Preparestatement than statement advantage, not much to say, today went to the Internet to check a bit.

The implementation of the ORM layer is to be explained later.

Implementation of spring-database operation component

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.