Guest User

Untitled

a guest
Jun 3rd, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. package com.hospital.emr;
  2.  
  3. import java.sql.*; // need to import the java.sql package to use JDBC
  4. import java.util.*; // needed for arraylist
  5.  
  6.  
  7. public class JdbcConnection
  8. {
  9.    
  10.     Connection conn;
  11.     Statement stmt;
  12.    
  13.     ArrayList<ResultSet> rset = new ArrayList<ResultSet>(); // create an arraylist of result sets
  14.    
  15.     // constructors
  16.     public JdbcConnection()
  17.         throws SQLException
  18.     {
  19.         // Load the Oracle JDBC driver
  20.         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  21.                
  22.         // Connect to the database
  23.  
  24.         Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.128:1521:xe", "hr","password");
  25.                
  26.         // Create a Statement
  27.         Statement stmt = conn.createStatement();
  28.                
  29.         System.out.println("Database connection successful.");
  30.     }
  31.    
  32.    
  33. }
Add Comment
Please, Sign In to add comment