Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.WingedMLGPro.API;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- public class MySQL
- {
- private static Connection connection;
- public static String username = "mc19421";
- public static String password = IM NOT THAT DUMB
- public static String database = "mc19421";
- public static String host = "23.94.121.2";
- public static String port = "3306";
- public static void connect() {
- if (!isConnected())
- try {
- connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static void close()
- {
- if (isConnected())
- try {
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static void update(String qry)
- {
- if (isConnected())
- try {
- connection.createStatement().executeUpdate(qry);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static ResultSet getResult(String qry)
- {
- if (isConnected()) {
- try {
- return connection.createStatement().executeQuery(qry);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
- public static boolean isConnected() {
- return connection != null;
- }
- public static void createTable() {
- if (isConnected())
- try {
- connection.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS SwiftyCreditsTest (UUID VARCHAR(100), PlayerName VARCHAR(100), Credits INT(10))");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement