How to optimize database linked Resources

Source: Internet
Author: User

Problem description:

To connect to the database for query on the page, the obtained results are displayed on the page. After each query, close is used to close the connection. Normally, it can be monitored in the database. After a connection is created, it will be released soon after the query is complete. However, when a query is complete, if you press F5 on the browser to refresh the page, the database connection will keep increasing, and the original connection is released slowly, and the database will soon be dragged to death.

Using the connection pool can only limit the total number of connections. If a person refresh quickly, the database will not die, but soon one will run out of resources and the application will be dragged to death,

Solution:

Do not create links in beans. They should be written in static methods of a class and passed as parameters so that each caller can use the same static link.

In the BEAN of the link, first check whether the static link is null. If not, directly reference the link. If yes, re-establish the link.

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.