Advertisement
Guest User

Untitled

a guest
May 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public void updateNoAutoCommitDB(LinkedList<String> queries) throws SQLException {
  2. Statement stmt = null;
  3.  
  4. try {
  5. connection.setAutoCommit(false);
  6. stmt = connection.createStatement();
  7. for(String query : queries){
  8. stmt.executeUpdate(query);
  9. }
  10. connection.commit();
  11. connection.setAutoCommit(true);
  12. } catch (SQLException e) {
  13. try {
  14. connection.rollback();
  15. connection.setAutoCommit(true);
  16. throw e;
  17. } catch (SQLException e1) {
  18. System.out.println("VIDINĖ KLAIDA: Nenumatyta SQL klaida!");
  19. }
  20. } finally {
  21. try {
  22. if(stmt != null) stmt.close();
  23. } catch (SQLException e) {
  24. System.out.println("VIDINĖ KLAIDA: Nenumatyta SQL klaida!");
  25. }
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement