我第一次尝试使用 c3p0 实现解决方案。我了解如何初始化连接池并从池中“ checkout ”连接,如下所示:
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass(driverClass);
cpds.setJdbcUrl(url);
cpds.setUser(username);
cpds.setPassword(password);
Connection conn = cpds.getConnection(username, password);
但我无法找到如何“ checkin ”已使用的连接以返回到池中。我该怎么做呢?我在这里做错了什么吗?
最佳答案
释放对用户来说是完全透明的。参见 here进一步解释。
一定要关闭()连接并且不保留进一步的引用(这会避免正确的 GC)。
关于java - c3p0 连接 checkin ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2102935/