清理JDBC资源时最佳做法是什么?为什么?我保持示例简短,因此只是清理ResultSet.
finally
{
if(rs != null)
try{ rs.close(); } catch(SQLException ignored) {}
}
Run Code Online (Sandbox Code Playgroud)
与
finally
{
try{ rs.close(); } catch(Exception ignored) {}
}
Run Code Online (Sandbox Code Playgroud)
我个人赞成第二种选择,因为它有点短.对此的任何意见都非常感谢.