Advertisement
Guest User

Untitled

a guest
May 2nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. @Override
  2. public boolean connect() {
  3. final Timming t = new Timming("MySQL ping").start();
  4. try {
  5. Class.forName("com.mysql.jdbc.Driver");
  6. Logger.info("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.name, this.user, this.pass);
  7. this.conn = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.name, this.user, this.pass + "?autoReconnect=true");
  8. Logger.info("Connected to the MySQL server!", "Connection ping " + t.stop().getExecutingTime() + "ms!");
  9. return true;
  10. }
  11. catch (ClassNotFoundException e) {
  12. Logger.warning("JDBC driver not found!", "Error: " + e.getMessage());
  13. e.printStackTrace();
  14. }
  15. catch (SQLException e2) {
  16. Logger.warning("Can not connect to a MySQL server!", "Error: " + e2.getMessage());
  17. e2.printStackTrace();
  18. }
  19. return false;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement