Tag Archives: getconnection

Differentiate services and sid in connection string


This might be a basic information for some experts out there but I felt its worth mentioning it here

how will u differentiate between services and the SID to connect to Oracle using JDBC in the connection string

for SID: it goes like
jdbc:oracle:thin:@localhost:1521:XE

for Services you specify like
jdbc:oracle:thin:@localhost:1521/XE

 Class.forName("oracle.jdbc.driver.OracleDriver");
 conn =
 DriverManager.getConnection(jdbc:oracle:thin:@localhost:1521/XE,system,tiger);
 Statement stmt = conn.createStatement();
 ResultSet rset = stmt.executeQuery(query);
Advertisements