Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. package dev.prettybytes.punishments.database;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.sql.Statement;
  7.  
  8. import dev.prettybytes.punishments.PrettyPunishments;
  9.  
  10. public class MySql {
  11.  
  12. public static Connection connection;
  13. public static Statement statement;
  14.  
  15. public static void doConnection(String host, String database, String user, String password) {
  16. try {
  17. Class.forName("com.mysql.jdbc.Driver");
  18. connection = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database, user, password);
  19. statement = connection.createStatement();
  20. statement.execute("CREATE TABLE IF NOT EXISTS prettyPunishments (user VARCHAR(255) NOT NULL, staffer VARCHAR(255) NOT NULL, tipo VARCHAR(255) NOT NULL, motivo VARCHAR(255) NOT NULL, data VARCHAR(255) NOT NULL, expira VARCHAR(255) NOT NULL)");
  21. } catch (ClassNotFoundException|SQLException e) {
  22. e.printStackTrace();
  23. PrettyPunishments.errorStop("ER92");
  24. }
  25. }
  26.  
  27. public static void undoConnection() {
  28. try {
  29. if(connection.isClosed()) return;
  30. statement.close();
  31. connection.close();
  32. } catch (SQLException e) {
  33. e.printStackTrace();
  34. PrettyPunishments.errorStop("ER92-A");
  35. }
  36. }
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement