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 org.bukkit.plugin.java.JavaPlugin;
- public class MainPlugin extends JavaPlugin{
- /*-- --*/
- // Database MySQL
- final String username = "root";
- final String password = "";
- final String url = "jdbc:mysql://localhost:3306/minecraft";
- public static Connection connection;
- /*-- --*/
- public void onEnable()
- {
- /*-- Load SelectCharacter Class --*/
- getServer().getPluginManager().registerEvents(new SelectCharacter(this), this);
- // Database MySQL
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- }
- catch(ClassNotFoundException e)
- {
- e.printStackTrace();
- System.err.println("jdbc driver unavailable!");
- }
- try
- {
- connection = DriverManager.getConnection(url,username,password);
- }
- catch(SQLException e)
- {
- e.printStackTrace();
- }
- }
- public void onDisable()
- {
- try
- {
- if(connection!=null && !connection.isClosed())
- {
- connection.close();
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement