Advertisement
Guest User

Untitled

a guest
Feb 12th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.     public void connectToDatabase(String user, String password)
  2.     {
  3.         Properties connectionProps = new Properties();
  4.         connectionProps.put("user", user);
  5.         connectionProps.put("password", password);
  6.         try
  7.         {
  8.             this.conn = DriverManager.getConnection("jdbc:oracle:thin:@//admlab2.cs.put.poznan.pl:1521/"
  9.                  + "dblab02_students.cs.put.poznan.pl", connectionProps);
  10.             System.out.println("Connection established");
  11.         }
  12.         catch(SQLException ex)
  13.         {
  14.             Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
  15.                     "Could not establish connection to database", ex);
  16.             System.exit(-1);
  17.         }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement