Guest User

Untitled

a guest
Sep 2nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. Connection connection = null;
  2. try {
  3.     // Load the JDBC driver
  4.     String driverName = "oracle.jdbc.driver.OracleDriver";
  5.     Class.forName(driverName);
  6.  
  7.     // Create a connection to the database
  8.     String serverName = "127.0.0.1";
  9.     String portNumber = "1521";
  10.     String sid = "mydatabase";
  11.     String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
  12.     String username = "username";
  13.     String password = "password";
  14.     connection = DriverManager.getConnection(url, username, password);
  15. } catch (ClassNotFoundException e) {
  16.     // Could not find the database driver
  17. } catch (SQLException e) {
  18.     // Could not connect to the database
  19. }
Add Comment
Please, Sign In to add comment