Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try (Connection connection = **strong text**DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "password")) {
- try (PreparedStatement stmt = connection.prepareStatement("DELETE * FROM PUBLISHER1 WHERE ID=1")) {
- stmt.executeUpdate();
- }
- // stmt is auto closed here, even if SQLException is thrown
- try (PreparedStatement stmt = connection.prepareStatement("DELETE *FROM PUBLISHER2 WHERE ID=2");
- stmt.executeUpdate();
- }
- // stmt is auto closed here, even if SQLException is thrown
- }
- // connection is auto closed here, even if SQLException is thrown
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement