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);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s