Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.util.sql;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.Properties;
- public class SQLHandler {
- private static final String DB = "edenpsc1_db";
- private static final String URL = "http://eden-ps.com";
- private static final String USER = "edenpsc1_db";
- private static final String PASS = "xzfc2fWDW@e9";
- private static final Properties prop;
- static {
- prop = new Properties();
- prop.put("user", USER);
- prop.put("pass", PASS);
- }
- public static Connection conn = null;
- /**
- * Connects to the database
- */
- public static void connect() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://" + URL + "/" + DB, prop);
- System.out.println("Connected to the sql system.");
- } catch (Exception e) {
- System.out.println("Setting sql connecting to false to help not cause anymore errors.");
- }
- }
- public static Connection getConnection() {
- try {
- if (conn == null || conn.isClosed()) {
- conn = DriverManager.getConnection("jdbc:mysql://" + URL + "/"
- + DB, prop);
- }
- } catch (SQLException e) {
- System.out.println(e);
- e.printStackTrace();
- }
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement