Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to connect to Oracle 11g using thin driver with service name & SID

2810041Dec 8 2014 — edited Apr 10 2015

Hi Experts,

Wish to know whether there is a common way to connect to Oracle 11g server using SID or service name.

Earlier I used jdbc:oracle:thin:@<<server>:<<port>>:<<SID>> for connecting to individual Oracle server instances.

Now I need to connect to Oracle RAC which provides service names. So I need to use jdbc:oracle:thin:@<<server>:<<port>>/<<service name>>.

This connection string is internally constructed by a program and user inputs <<server>>, <<port>> and <<SID>> or <<Service Name>>. Now this requires two different connection strings based on the input whether its SID or service name.

Is there a common connection string for these two? Based on some articles like this, I understood that we can generically use jdbc:oracle:thin:@<<server>:<<port>>/<<service>>, whether for SID and service.

When I tried this format with SID, I am getting the below error. What I tried is jdbc:oracle:thin:@myoracleserver:1521/ORCL, where ORCL is the SID

java.sql.SQLException: Listener refused the connection with the following error:

ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

Request your help in solving this. What I want is a single connection string whether its SID or service. Any help is of great value.

Regards

Sunil

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 8 2015
Added on Dec 8 2014
2 comments
3,619 views