Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.terabitth.SelectChar;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- import org.bukkit.plugin.java.JavaPlugin;
- public class MainPlugin extends JavaPlugin{
- /*-- --*/
- // Database MySQL
- String host = "localhost";
- int port = 3306;
- String database = "minecraft";
- String username = "root";
- String password = "";
- public static Connection connection;
- /*-- --*/
- public void onEnable()
- {
- /*-- Load SelectCharacter Class --*/
- getServer().getPluginManager().registerEvents(new SelectCharacter(this), this);
- // Database MySQL
- try
- {
- openConnection();
- Statement statement = connection.createStatement();
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- public void openConnection() throws SQLException, ClassNotFoundException
- {
- if (connection != null && !connection.isClosed()) {
- return;
- }
- synchronized (this) {
- if (connection != null && !connection.isClosed()) {
- return;
- }
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement