Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String username = "";
- public static String passwort = "";
- public static String host = "";
- public static int port = 3360;
- public static String database = "";
- public static Connection con;
- public static void connect() {
- if(!isConnected()) {
- try {
- con = DriverManager.getConnection("jdbc:mysql://"+host+":"+port+"/"+database, username, passwort);
- Messages.bungeelogger(Level.INFO, "§5MySQL §7- §aDie Verbindung steht nun!");
- } catch (SQLException e) {
- e.printStackTrace();
- Messages.bungeelogger(Level.SEVERE, "§5MySQL §7- §cEs konnte keine Verbindung hergestellt werden!");
- }
- }
- }
- public static void close() {
- if(!isConnected()) {
- try {
- con.close();
- Messages.bungeelogger(Level.INFO, "§5MySQL §7- §eDie Verbindung wurde geschlossen!");
- } catch (SQLException e) {
- e.printStackTrace();
- Messages.bungeelogger(Level.SEVERE, "§5MySQL §7- §cEs wurde keine Aktive Verbindung gefunden!");
- }
- }
- }
- public static boolean isConnected() {
- return con != null;
- }
- public static void update(String qry) {
- try {
- PreparedStatement ps = con.prepareStatement(qry);
- ps.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static ResultSet getResult(String qry) {
- try {
- PreparedStatement ps = con.prepareStatement(qry);
- return ps.executeQuery();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement