Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package me.ase.CommandCheckerBlocker.DBConnect;
  2.  
  3. import java.sql.*;
  4.  
  5. public class databaseConnection {
  6.     static private Connection connection;
  7.  
  8.     public static Connection getConnection() {
  9.         String host = "sql.pebblehost.com";
  10.         String user = "customer_73953";
  11.         String db = "customer_73953";
  12.         String pass = "3497b6f741";
  13.         if (connection == null) {
  14.             try {
  15.             Class.forName("com.mysql.jdbc.Driver");
  16.             connection = DriverManager.getConnection("jdbc:mysql://" + host + "/" + db, user, pass);
  17.             } catch (Exception e) {
  18.                 e.printStackTrace();
  19.             }
  20.         }
  21.         return connection;
  22.  
  23.     }
  24.  
  25.     public static void setData(String string) throws Exception {
  26.         databaseConnection.getConnection().createStatement().executeUpdate(string);
  27.     }
  28.  
  29.     public static ResultSet getData(String string) throws Exception {
  30.         return databaseConnection.getConnection().createStatement().executeQuery(string);
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement