Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.trollc.swampessentials.utils;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import com.mysql.jdbc.Connection;
- import me.trollc.swampessentials.Main;
- public class SQL {
- private Connection connection;
- private Main pl;
- public SQL(Main plugin) {
- this.pl = plugin;
- }
- public void openConnection() throws SQLException, ClassNotFoundException {
- if (this.connection != null && !this.connection.isClosed()) {
- return;
- }
- synchronized (this) {
- if (this.connection != null && !this.connection.isClosed()) {
- return;
- }
- Class.forName("com.mysql.jdbc.Driver");
- this.connection = (Connection) DriverManager.getConnection("jdbc:mysql://" + this.pl.getConfig().getString("mysql.host") + ":" + this.pl.getConfig().getInt("mysql.port") + "/" + this.pl.getConfig().getString("mysql.db"), this.pl.getConfig().getString("mysql.user"), this.pl.getConfig().getString("mysql.pass"));
- }
- }
- public Connection getConnection() {
- return this.connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement