如果發生異常,請嘗試使用資源關閉所有打開的資源?如果發生異常,請嘗試使用資源關閉資源?
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