c3p0连接签入 [英] c3p0 Connection Checkin

查看:111
本文介绍了c3p0连接签入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试首次使用c3p0实现解决方案。我了解如何初始化连接池并从池中检出连接,如下所示:

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);

但是我很难找到如何签入一个已经使用过的Connection并返回到池。我将如何去做呢?

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?

推荐答案

释放对用户完全透明。有关详细说明,请参见此处

Freeing up is totally transparent to the user. See here for further explanation.

请务必关闭Connection(),不要再保留任何引用(这将避免适当的GC)。

Be shure to close() the Connection and hold no further reference (that would avoid proper GC).

这篇关于c3p0连接签入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆