Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- */
- package com.kittyirc.io;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.util.logging.Logger;
- import com.kittyirc.Constants;
- /**
- * @author Michael
- *
- */
- public class SqlConnector {
- private static final Logger logger = Logger.getLogger(SqlConnector.class
- .getName());
- private static final SqlConnector INSTANCE = new SqlConnector();
- private Connection connection;
- private SqlConnector() {
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection("jdbc:mysql://"
- + Constants.SQL_IP + "/" + Constants.SQL_DB,
- Constants.SQL_USER, Constants.SQL_PASS);
- logger.info("Connected to " + Constants.SQL_IP + " : "
- + Constants.SQL_DB + " .");
- } catch (Exception e) {
- logger.severe("SQL Cannot connect to specified database.");
- e.printStackTrace();
- System.exit(0);
- }
- }
- public static SqlConnector getSqlConnector() {
- return INSTANCE;
- }
- /**
- * @return the connection
- */
- public Connection getConnection() {
- return connection;
- }
- }
Add Comment
Please, Sign In to add comment