Guest User

Untitled

a guest
Feb 9th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package pl.kti.pk2.dbdemo.data;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class DBManager {
  8. private static String _host = "150.254.204.135";
  9. private static String _port = "3306";
  10. private static String _user = "pk2_student_01";
  11. private static String _pass = "100dent;";
  12. private static String _db = "pk2_01";
  13.  
  14. private static Connection connection;
  15.  
  16. public static Connection getConnection() throws ClassNotFoundException, SQLException {
  17. if (connection == null) {
  18. Class.forName("com.mysql.jdbc.Driver");
  19. String url = "jdbc:mysql://" + _host + ":" + _port + "/" + _db + "";
  20. connection = DriverManager.getConnection(url, _user, _pass);
  21. }
  22. return connection;
  23. }
  24. }
Add Comment
Please, Sign In to add comment