Guest User

Untitled

a guest
Jun 11th, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4.  
  5.  
  6. public class MySQL {
  7. public static final String USERNAME = "user-root";
  8. public static final String PASSWORD = "password=";
  9. public static final String DB_URL = "jdbc:mysql://localhost:3306/person1?";
  10.  
  11.  
  12. public MySQL(){
  13. try {
  14. Class.forName("com.mysql.jdbc.Driver");
  15. } catch (ClassNotFoundException e) {
  16. // TODO Auto-generated catch block
  17. e.printStackTrace();
  18. }
  19. }
  20.  
  21. public Connection getCon() {
  22. Connection con = null;
  23. try {
  24. con = DriverManager.getConnection(DB_URL+USERNAME+"&"+PASSWORD);
  25. } catch (SQLException e) {
  26. // TODO Auto-generated catch block
  27. e.printStackTrace();
  28. }
  29. return con;
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment