dotnet Database connection pooling problem

Source: Internet
Author: User
Tags connection pooling dotnet odbc

The timeout period has expired. The timeout has expired before getting a connection from the pool. This may occur because all pool connections have been used and the maximum pool size has been reached.

Solutions
1. Inside the code, turn off the connection that is not closed
2. Expand the sharing pool by the following methods:
The workaround can be to modify the connection lifetime of the connection pool because the default value is 60 seconds, which is the time that the connection can be saved in the pool after it has been freed from the application.
The specific steps are as follows:
If it is ODBC, you can manually change it in the ODBC Data Source Administrator, which is located under the "Programs"-> "Start" menu, "adminstrative Tools" (Chinese Name: administrative tool), or open "ODBC data Source Administrator" from the Control Panel (Chinese name: Console), and then select the Connection pooling (connection Pooling) tab and double-click the SQL Server, select Pool connetions to this drive (use pool to connect the driver), and change the following time to a larger 60 seconds, such as 120.
If this is a SqlConnection shared connection, specify a value for the ConnectionString property connection lifetime numeric name, which by default is 0, which means that the connection will never be automatically removed from the pool. If a different value is specified, the value is compared to the creation time and the current time of the connection once the connection is returned to the pool. If the lifetime exceeds the value of the connection lifetime, the connection is removed from the pool.

The problem is that the connection to the database is not turned off, and it takes time for the system to recycle automatically. The solution is to change the size of the connection pool. Add the following code after the connection string: enlist=true; Pooling=true; Max Pool size=300; Min Pool size=0; Connection Lifetime=300;user Id=sa;packet size=1000
Packet size argument takes any integer value from 512 to 32767

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.