Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MySQL {
- public static Connection con;
- public static Connection connect(String host, int port, String database, String user, String password){
- try{
- con = DriverManager.getConnection("jdbc:mysql://"+host+":"+port+"/"+database+"?autoReconnect=true",user,password);
- Bukkit.getConsoleSender().sendMessage("§aMySQL Is now connected with all servers.");
- } catch(SQLException e){
- e.printStackTrace();
- Bukkit.getConsoleSender().sendMessage("§cMySQL Can't connect with all servers." + e.getMessage());
- }
- return con;
- }
- public static void disconnect(){
- try{
- con.close();
- }catch(SQLException e){
- e.printStackTrace();
- }
- }
- public static boolean hasConnection(){
- if(con != null){
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement