|
Connection con = DriverManager.getConnection (url, "123", "123");
Statement stmt = con.createStatement ();
ResultSet rs = stmt.executeQuery (sql);
Suppose there is a long code (20 lines)
Suppose that the code in these 20 lines reports a SQLException or other end
rs.close
stmt.close
con.close
The above three sentences will not be executed, and the connection cannot be closed
How can I close all connections to the database and the method still throws an exception upwards?
This method throws SQLException
Try catch words! too big! !! |
|