参见英文答案 >
Closing Database Connections in Java 6个
我有一个连接池.在getConnection()方法中,我调查从队列到变量的连接,并检查它是否被isClosed()方法关闭.如果它关闭,我通过DriverManager.getConnection(url,user,password)方法设置变量new connection.
问题是:在重写varible之前,是否需要通过close()方法关闭连接mannualy以确保垃圾收集器将收集连接?
最佳答案 不需要(推荐).
如果在关闭连接后手动调用close(),则不会对该连接对象执行任何操作.