Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection con;
- private FileConfiguration cfgmysql = XeventoFFA.getInstance().filemanager.getMySQLConfig();
- public void connect() {
- if(!isConnected()) {
- String HOST = cfgmysql.getString("mysql.host");
- String DATABASE = cfgmysql.getString("mysql.datenbank");
- String USER = cfgmysql.getString("mysql.user");
- String PASSWORD = cfgmysql.getString("mysql.passwort");
- try {
- con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":3306/" + DATABASE + "?autoReconnect=true", USER, PASSWORD);
- System.out.println("[MySQL] Verbindung wurde aufgebaut");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public void disconnect() {
- if(isConnected()) {
- try {
- con.close();
- System.out.println("[MySQL] Verbindung wurde geschlossen");
- } catch(SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public boolean isConnected() {
- return(con == null ? false : true);
- }
- public Connection getConnection() {
- return con;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement