Advertisement
Guest User

Untitled

a guest
Sep 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4.  
  5. import pl.sbhub.Main;
  6.  
  7. public class DatabaseManager {
  8.  
  9. private static Connection connection;
  10.  
  11. public static void getConnection(){
  12.  
  13. try {
  14. connection = (Connection) DriverManager.getConnection("jdbc:mysql://" + Main.getInstance().getConfig().getString("mysql.host") + ":" + Main.getInstance().getConfig().getString("mysql.port") + "/" + Main.getInstance().getConfig().getString("mysql.database") + "","" + Main.getInstance().getConfig().getString("mysql.user") + "", "" + Main.getInstance().getConfig().getString("mysql.password") + "");
  15. if(connection != null){
  16. Main.getInstance().getLogger().info("[CommandSyncSQL] has connected to MySQL!");
  17. }
  18. } catch (SQLException e) {
  19. // TODO Auto-generated catch block
  20. e.printStackTrace();
  21. }
  22.  
  23. }
  24.  
  25. public static Connection returnConnection(){
  26. return connection;
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement