Connection Pool Problems

Source: Internet
Author: User
Tags finally block

Solution 1

I think it may be because of concurrent operations. Datareader is exclusively connected, that is, your program may be designed incorrectly. For example, if the maximum connection is set to 100 and 100 users use datareader to read the database content at the same time, the above error occurs when the connection pool is no longer connected when 101st users read the data. Datareader is exclusively connected, and each datareader occupies a connection. Of course, this happens occasionally, so it takes a long time, because only concurrent operations that exceed the maximum number of connections in the connection pool will occur. In addition, you can only temporarily reduce the number of concurrent connections. If you increase the number of concurrent connections to 200, what if there are 201 concurrent operations? You said that you can't use the close () method of the connection object, because the close () method only closes the connection, but the connection is not released and is still occupied by this object, to release a connection, you must use the dispose () method of the connection to explicitly release the connection. Otherwise, the connection occupied by this object can be released only when garbage collection is performed. In this case, the error "time-out has reached" will certainly occur.

1. modify several key pages or frequently accessed database access operations. Use dataadapter and dataset to obtain database data. Do not use datareader.
2. Use the data cache on the page for accessing the database. If the data on the page is not updated frequently (updated several minutes), the cache object can be used without accessing the database, this greatly reduces the number of connections.
3. modify the code and call dispose () after close.
4. We recommend that you modify Database Operations to create your own database operation proxy class, inherit from the system. idisposable interface, and forcibly release resources. In this way, there will be no insufficient connections.

Solution 2

Solution (*): Web. in config: Add Max pool size = 512; server = Local; uid =; Pwd =; database = 2004; Max pool size = 512; "> once and for all.

Solution 3

It is estimated that the connection object is not close. You don't need to dispose, but datareader should be closed after it is used up, but it is okay if it is not closed, but the connection object will never be used, as long as you close the connection object, there will be no problems.

The operations of the connected object after open are put in the try block, followed by a Finally block: conn. Close ();

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: 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.