Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  public Conexion Conectar()
  2.     {
  3.         try {
  4.            
  5.             Class.forName("oracle.jdbc.OracleDriver");
  6.             String bd = "jdbc:oracle:thin:@localhost:1521:XE";
  7.             conexion = DriverManager.getConnection(bd,"inventario","system");  
  8.            
  9.             if(conexion != null){
  10.                 System.out.println("conexion exitosa");
  11.             }else{
  12.                 System.out.println("conexion fallida");
  13.             }
  14.            
  15.         } catch (SQLException e) {
  16.             System.out.println("ERROR SQL: "+e.getMessage());
  17.         } catch(Exception ex){
  18.             System.out.println("OTRO ERROR: "+ex.getMessage());
  19.         }
  20.        
  21.         return this;
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement