Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public static Connection getConnection() {
  2.  
  3.  
  4. final Logger resultLog = Logger.getLogger(DataClassInsert.class);
  5. String driver = Tools.propertieReader("driver");
  6. String url = Tools.propertieReader("url");
  7. String username = Tools.propertieReader("username");
  8. String password = Tools.propertieReader("password");
  9.  
  10.  
  11. Connection conn = null;
  12. try {
  13. Class.forName(driver);
  14. conn = DriverManager.getConnection(url, username, password);
  15. } catch (SQLException e) {
  16. e.printStackTrace();
  17.  
  18. String SQLmessage = e.getMessage();
  19. String SQLstate = e.getSQLState();
  20. int vendorcode = e.getErrorCode();
  21.  
  22. resultLog.error("An excetion hasse occured");
  23. resultLog.error("Message : " + SQLmessage);
  24. resultLog.error("Sate : " + SQLstate);
  25. resultLog.error("VendorCode : " + vendorcode);
  26. System.exit(0);
  27. } catch (ClassNotFoundException e) {
  28. e.printStackTrace();
  29. resultLog.error("Exception ; " + e.getMessage());
  30. }
  31. return conn;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement