Advertisement
TeamfA

cai gi á

Feb 6th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class MySQL {
  2. public static Connection con;
  3. public static Connection connect(String host, int port, String database, String user, String password){
  4. try{
  5. con = DriverManager.getConnection("jdbc:mysql://"+host+":"+port+"/"+database+"?autoReconnect=true",user,password);
  6. Bukkit.getConsoleSender().sendMessage("§aMySQL Is now connected with all servers.");
  7. } catch(SQLException e){
  8. e.printStackTrace();
  9. Bukkit.getConsoleSender().sendMessage("§cMySQL Can't connect with all servers." + e.getMessage());
  10. }
  11. return con;
  12. }
  13. public static void disconnect(){
  14. try{
  15. con.close();
  16. }catch(SQLException e){
  17. e.printStackTrace();
  18. }
  19. }
  20. public static boolean hasConnection(){
  21. if(con != null){
  22. return true;
  23. }
  24. return false;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement