Advertisement
Guest User

Untitled

a guest
Apr 7th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public void sql_setup(String name)
  2. {
  3.  
  4. host = configcfg.getString("sql." + name.toLowerCase() + ".host");
  5. port = configcfg.getInt("sql." + name.toLowerCase() + ".port");
  6. database = configcfg.getString("sql." + name.toLowerCase() + ".database");
  7. username = configcfg.getString("sql." + name.toLowerCase() + ".username");
  8. password = configcfg.getString("sql." + name.toLowerCase() + ".password");
  9.  
  10. try
  11. {
  12. synchronized (this)
  13. {
  14. if (getConnection() != null && getConnection().isClosed())
  15. {
  16. return;
  17. }
  18. Class.forName("com.mysql.jdbc.Driver");
  19. setConnection(DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password));
  20.  
  21. _Server.log("SQL" + name .toUpperCase() + " - Added Successfully");
  22. }
  23. }
  24. catch (SQLException e)
  25. {
  26. e.printStackTrace();
  27. }
  28. catch (ClassNotFoundException e)
  29. {
  30. e.printStackTrace();
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement