简体   繁体   中英

Is it necessary to explicitly close connections in Tomcat JDBC pool?

Example code in " http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html " explicitly closes a connection after it is used.

However according to my understanding, should not it be the connection pool's responsibility to manage active and idle connections?

Why would not I want a connection to be re-used by another transaction?

You must close the connection so that you can release it back to the pool. The "Connection" you get from the pool does not, per se, represent the actual, physical connection to the DB. Rather it's a wrapper. So, closing the connection informs the pool that it is free for use by other clients of the pool.

您需要调用Connection.close()来返回到池的连接,它实际上并不关闭底层连接。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM