Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1.  
  2. package conexion;
  3.  
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.SQLException;
  7.  
  8. public class Conexion {
  9. private static String url = "jdbc:mysql://localhost:3306/bd_criminales";
  10. private static String driverName = "com.mysql.jdbc.Driver";
  11. private static String username = "root";
  12. private static String password = "";
  13. private static Connection con;
  14. // private static String urlstring;
  15.  
  16. public static Connection getConnection() {
  17. try {
  18. Class.forName(driverName);
  19. try {
  20. con = DriverManager.getConnection(url, username, password);
  21. } catch (SQLException ex) {
  22.  
  23. System.out.println("Fallo en la conexion.");
  24. }
  25. } catch (ClassNotFoundException ex) {
  26.  
  27. System.out.println("No se encuentra driver.");
  28. }
  29. return con;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement