Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package triplx.lobby.hub.mysql;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class SQLManager {
- public String host, database, username, password, table;
- public int port;
- public static SQLManager getInstance(){
- return new SQLManager();
- }
- private Connection connection;
- public void setupMySQL(){
- host = "host";
- port = 3306;
- database = "**";
- username = "**";
- password = "**";
- table = "player_lobby_settings";
- try {
- synchronized (this){
- if (getConnection() != null && !getConnection().isClosed()){
- return;
- }
- Class.forName("com.mysql.jdbc.Driver");
- setConnection(DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password));
- Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "MySQL Connected!");
- }
- } catch (SQLException | ClassNotFoundException e){
- e.printStackTrace();
- }
- }
- public Connection getConnection() {
- return connection;
- }
- private void setConnection(Connection connection){
- this.connection = connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement