Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. static Connection conn = null;
  2.     static String dbURL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
  3.     static String user = "labs";
  4.     static String password = "labs";
  5.    
  6.     public JdbcEx1() {}
  7.    
  8.     public static void main(String[] args) throws SQLException
  9.     {
  10.         try{
  11.             Class.forName("oracle.jdbc.driver.OracleDriver");
  12.         }catch(ClassNotFoundException e){
  13.             System.err.println(e.getMessage());
  14.         }
  15.        
  16.         try{
  17.             conn = DriverManager.getConnection(dbURL, user, password);
  18.             conn.clearWarnings();
  19.             System.out.println("Connection opened! for driver ==> Oracle 11XE");
  20.         }catch(SQLException e){
  21.             System.err.println(e.getMessage());
  22.         }finally{
  23.             if(!conn.isClosed()){
  24.                 conn.close();
  25.                 System.out.println("Connection closed! Oracle");
  26.             }
  27.         }
  28.     }
  29.     //End of main method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement