c3p0 连接检查
我第一次尝试使用 c3p0 实现解决方案。我了解如何初始化连接池并从池中“签出”连接,如下所示:
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass(driverClass);
cpds.setJdbcUrl(url);
cpds.setUser(username);
cpds.setPassword(password);
Connection conn = cpds.getConnection(username, password);
但是我无法找出如何“签入”已使用的连接以返回到池中。我该怎么做呢?我在这里做错了什么吗?
I'm trying to implement a solution with c3p0 for the first time. I understand how to initialize the connection pool and "checkout" a Connection from the pool as follows:
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass(driverClass);
cpds.setJdbcUrl(url);
cpds.setUser(username);
cpds.setPassword(password);
Connection conn = cpds.getConnection(username, password);
But I am having trouble finding out how to "checkin" an already used Connection to go back into the pool. How would I go about doing this? Is there something that I'm doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
释放对用户来说是完全透明的。请参阅此处了解更多说明。
请务必 close() 连接并且不再保留进一步的引用(这将避免正确的 GC)。
Freeing up is totally transparent to the user. See here for further explanation.
Be shure to close() the Connection and hold no further reference (that would avoid proper GC).
我相信当您关闭连接时,连接会返回到池中。
I believe the connection is returned to the pool when you close it.