Guest User

Untitled

a guest
Dec 1st, 2017
64
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 mysqlSetup() {
  2. host = configmmysql.getConfig().getString("host");
  3. port = configmmysql.getConfig().getInt("port");
  4. database = configmmysql.getConfig().getString("database");
  5. username = configmmysql.getConfig().getString("username");
  6. password = configmmysql.getConfig().getString("password");
  7. table = configmmysql.getConfig().getString("table");
  8. try {
  9.  
  10. synchronized (this) {
  11. if (getConnection() != null && !getConnection().isClosed()) {
  12. return;
  13. }
  14.  
  15. Class.forName("com.mysql.jdbc.Driver");
  16. setConnection(DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database,
  17. username, password));
  18. }
  19. } catch (SQLException e) {
  20. e.printStackTrace();
  21. } catch (ClassNotFoundException e) {
  22. e.printStackTrace();
  23. }
  24. }
Add Comment
Please, Sign In to add comment