Advertisement
Guest User

Untitled

a guest
May 19th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package de.shadow.system.mysql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. import org.bukkit.Bukkit;
  8.  
  9. public class MySQL {
  10.  
  11. public static Connection con;
  12.  
  13. public static Connection connect(String host, int port, String database, String user, String password) {
  14. try {
  15. con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true", user, password);
  16. Bukkit.getConsoleSender().sendMessage("§aDas CoinSystem ist mit MySQL verbunden!");
  17. } catch (SQLException e) {
  18. Bukkit.getConsoleSender().sendMessage("§cDas CoinSystem konnte sich nicht mit MySQL verbinden!: " + e.getMessage());
  19. e.printStackTrace();
  20. }
  21.  
  22. return con;
  23. }
  24.  
  25. public static void disconnect() {
  26. try {
  27. con.close();
  28. } catch (SQLException e) {
  29. e.printStackTrace();
  30. }
  31. }
  32.  
  33. public static boolean hasConnection() {
  34. if (con != null) {
  35. return true;
  36. }
  37. return false;
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement