Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [13/04/2016 14:44:40] Naizox | Dev': connection = DriverManager.getConnection(url_base + host, username, passeword);
- [13/04/2016 14:46:13] Naizox | Dev': package fr.littlemc.api.mysql;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import net.md_5.bungee.BungeeCord;
- public class MySQL {
- private static String url_base = "jdbc:mysql://";
- private static String host = "localhost/******";
- private static String username = "*****";
- private static String passeword = "*******";
- private static Connection connection;
- public static Connection getConnection() {
- return connection;
- }
- public static boolean isConnected() {
- try {
- if ((connection == null) || (connection.isClosed())) {
- return false;
- }
- return true;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- @SuppressWarnings("deprecation")
- public static void connection() {
- if (!isConnected()) {
- try {
- BungeeCord.getInstance().getConsole()
- .sendMessage("§7[§eLittleAPI§7] §aTentative de connexion a la base de donnée ...");
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection(url_base + host, username, passeword);
- BungeeCord.getInstance().getConsole().sendMessage("§7[§eLittleAPI§7] §aConnexion réussie !");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
- public static void deconnection() {
- if (isConnected()) {
- try {
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement