c3p0 Connection Checkin

╄→гoц情女王★ 提交于 2020-01-03 13:09:34

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/2102935/c3p0-connection-checkin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!