Advertisement
Guest User

baza

a guest
Jan 27th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public void ucitajDrajver() {
  2. try {
  3. Class.forName("com.mysql.jdbc.Driver");
  4. } catch (ClassNotFoundException ex) {
  5. Logger.getLogger(DBBroker.class.getName()).log(Level.SEVERE, null, ex);
  6. }
  7. }
  8.  
  9. public void otvoriKonekciju() {
  10. String url = "jdbc:mysql://localhost:3306/prosoftjan18";
  11. String dbuser = "root";
  12. String dbpassword = "";
  13. try {
  14. konekcija = DriverManager.getConnection(url, dbuser, dbpassword);
  15. konekcija.setAutoCommit(false);
  16. System.out.println("otvori");
  17. } catch (SQLException ex) {
  18. Logger.getLogger(DBBroker.class.getName()).log(Level.SEVERE, null, ex);
  19. }
  20. }
  21.  
  22. public void zatvoriKonenciju() {
  23. try {
  24. konekcija.close();
  25. } catch (SQLException ex) {
  26. Logger.getLogger(DBBroker.class.getName()).log(Level.SEVERE, null, ex);
  27. }
  28. }
  29.  
  30. public void commit() {
  31. try {
  32. konekcija.commit();
  33. } catch (SQLException ex) {
  34. Logger.getLogger(DBBroker.class.getName()).log(Level.SEVERE, null, ex);
  35. }
  36. }
  37.  
  38. public void rollback() {
  39. try {
  40. konekcija.rollback();
  41. } catch (SQLException ex) {
  42. Logger.getLogger(DBBroker.class.getName()).log(Level.SEVERE, null, ex);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement