Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle EasyConnect connection string using a SID?

I'm trying to connect to an Oracle database through code (Ruby/DBI, but that's irrelevant) using an EasyConnect connection string. All of the Oracle documentation says to specify the connection string as //hostname:port/service_name. I don't have a service_name for the database that I need to connect to, I have a SID instead. Is there a way to create an EasyConnect connection string using a SID instead of a service name?

My connection code looks like this:

DBI.connect("DBI:OCI8://localhost:9000/the_sid", "username here", "password here")

I keep trying different things, and depending on what I try, I get one of two error messages:

ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (DBI::DatabaseError)
ORA-12154: TNS:could not resolve the connect identifier specified (DBI::DatabaseError)
like image 521
Jon Kruger Avatar asked Jan 10 '11 18:01

Jon Kruger


People also ask

What is SID in Oracle connection string?

A sid is the Site Identifier. It, plus the oracle_home, uniquely identify a database instance on a single machine. If you are on the machine with the database, you only need the oracle_sid and oracle_home to get connected directly.

How do I connect my Ezconnect?

To enable Easy Connect Naming from Net Manager: From the Available Methods list, select EZCONNECT, and then click the right-arrow button. From the Selected Methods list, select EZCONNECT, and then use the Promote button to move the selection to the top of the list. Choose File > Save Network Configuration.


1 Answers

Did you try the SID as the SERVICE name? You can usually specify a SID where a service is asked for. SERVICE_NAMES typically defaults to the SID. At a SQL command prompt, enter:

SQL> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      sid

SQL> 

The value(s) in the VALUE column is/are the service name(s) the database is registered as.

like image 112
DCookie Avatar answered Nov 15 '22 11:11

DCookie