c3p0 连接检查

发布于 2024-08-18 17:02:47 字数 358 浏览 12 评论 0原文

我第一次尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若水般的淡然安静女子 2024-08-25 17:02:48

释放对用户来说是完全透明的。请参阅此处了解更多说明。

请务必 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).

我们的影子 2024-08-25 17:02:48

我相信当您关闭连接时,连接会返回到池中。

I believe the connection is returned to the pool when you close it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文