In general, the database connection pool is configured in Tomcat, and we constantly establish database connections. This is the case if the database connection is not closed.
Common: cannot get a connection, pool exhaustedcannot get a connection, pool
Exhausted
. In fact, this is because the connections in the connection pool are exhausted. In fact, we should develop a good habit in development, that is, we should close the connection immediately after the connection is used up.
This is a good solution.
Some people may say that the database connection should be closed every time the pool connection is used up, so the pool will not work anymore? Isn't it because the connection is closed once and the connection is established again? Isn't the efficiency still low?
Otherwise, call con. close () does not actually close the connection, but allows the pool to store the connection back to the pool and allocate it to other clients for use.
And does not affect the efficiency of the connection pool.
Of course, this is not the only solution, but I think it is the best solution. However, if you forget to close the database connection during programming, there are still other solutions: (of course, it is best to disable con in finally)
1. You can restart your Tomcat server. This is the best solution, but it has no technical skills.
2. In the configuration file of the data source, adjust the value of the maxactive attribute to a greater value, such as 100