Possible Duplicate:
Why would you ever implement finalize()?
我看到了一些java文档,其代码如下:
public void finalize() {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
}
}
}
- Is closing a
Connection
in thefinalize
method best practice? - Is it enough to close the
Connection
or does one need to also close other objects such asPreparedStatement
?