Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1.     public Connection conectar() {
  2.        
  3.         try {
  4.             Class.forName("com.mysql.jdbc.Connection");
  5.             this.conexion = (Connection) DriverManager.getConnection(this.url,this.usuario,this.password);
  6.             if (this.conexion != null) {
  7.                 return this.conexion;
  8.             }
  9.         }
  10.         catch(SQLException ex) {
  11.             System.out.println("Hubo un problema al intentar conectarse con la base de datos "+this.url);
  12.         }
  13.         catch(ClassNotFoundException ex) {
  14.             System.out.println(ex);
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement