Advertisement
Guest User

Untitled

a guest
Mar 25th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. package db;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.util.logging.Level;
  7. import java.util.logging.Logger;
  8.  
  9. class DBConnector {
  10.  
  11. private final String IP = "207.154.197.204";
  12. private final int PORT = 3306;
  13. private final String DATABASE = "FogDB";
  14. private final String USERNAME = "bade";
  15. private final String PASSWORD = "3201";
  16.  
  17. public Connection getConnection() {
  18. Connection conn = null;
  19. try {
  20. Class.forName("com.mysql.jdbc.Driver").newInstance();
  21. String url = "jdbc:mysql://" + IP + ":" + PORT + "/" + DATABASE + "?useUnicode=true&characterEncoding=utf8";
  22. conn = (Connection) DriverManager.getConnection(url, USERNAME, PASSWORD);
  23. } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
  24. Logger.getLogger(DBConnector.class.getName()).log(Level.SEVERE, null, ex);
  25. }
  26.  
  27. return conn;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement