Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package db;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- class DBConnector {
- private final String IP = "207.154.197.204";
- private final int PORT = 3306;
- private final String DATABASE = "FogDB";
- private final String USERNAME = "bade";
- private final String PASSWORD = "3201";
- public Connection getConnection() {
- Connection conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String url = "jdbc:mysql://" + IP + ":" + PORT + "/" + DATABASE + "?useUnicode=true&characterEncoding=utf8";
- conn = (Connection) DriverManager.getConnection(url, USERNAME, PASSWORD);
- } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
- Logger.getLogger(DBConnector.class.getName()).log(Level.SEVERE, null, ex);
- }
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement