Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.shadow.system.mysql;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import org.bukkit.Bukkit;
- 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("§aDas CoinSystem ist mit MySQL verbunden!");
- } catch (SQLException e) {
- Bukkit.getConsoleSender().sendMessage("§cDas CoinSystem konnte sich nicht mit MySQL verbinden!: " + e.getMessage());
- e.printStackTrace();
- }
- 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