如果发生异常,请尝试使用资源关闭所有打开的资源?如果发生异常,请尝试使用资源关闭资源?
private void insertUserInAccessTable(int user_id) throws SQLException {
final String sql = "bla bla";
try(Connection con = ...; PreparedStatement ps = ...) {
...
if(i==0) throw new SQLException();
}
}
这就是试用资源的重点。 – 2014-12-19 07:35:23