Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import pl.sbhub.Main;
- public class DatabaseManager {
- private static Connection connection;
- public static void getConnection(){
- try {
- 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") + "");
- if(connection != null){
- Main.getInstance().getLogger().info("[CommandSyncSQL] has connected to MySQL!");
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static Connection returnConnection(){
- return connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement