Guest User

Untitled

a guest
Dec 1st, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 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. synchronized (this) {
  10. if (getConnection() != null && !getConnection().isClosed()) {
  11. return;
  12. }
  13.  
  14. Class.forName("com.mysql.jdbc.Driver");
  15. setConnection(DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database,
  16. username, password));
  17. }
  18. } catch (SQLException e) {
  19. e.printStackTrace();
  20. } catch (ClassNotFoundException e) {
  21. e.printStackTrace();
  22. }
  23. }
Add Comment
Please, Sign In to add comment