How can you improve the performance of accessing the database using JDBC?

Source: Internet
Author: User

1. Use data connection pooling (Connection pool) to avoid using drivermanager.getconnection.

2. Reasonable configuration data connection pool parameters, set the initial size of the data connection pool, the maximum number of connections, the connection time-out and so on.

3. Select the appropriate transaction level and select a different transaction level according to the different database operation types.

4. Close the connection in a timely manner, without shutting down will seriously affect the performance of the system and even cause a system strike.

5. Optimize statement

1) Choose the appropriate statement, according to different database operation Choose Statement, PreparedStatement or CallableStatement, the specific choice which can be understood through the search engine.

2) Use batch as much as possible, which reduces the number of calls to JDBC. The specific method is to use Statement.addbatch ("Your SQL") to add batch, and then execute Statement.executebatch () to execute together.

3) Close STATEMENT6 after statement execution. Optimize your SQL and try to reduce your result set, not every time "select * from XXX" 7. Using some caching tools for caching, especially for large data volumes, a reasonable cache tends to significantly improve the performance of the system.

How can you improve the performance of accessing the database using JDBC?

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.