7
votes

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)
1
Are you sure you need the hostname and port number at all? The error message seems to indicate that you have TNS listener running. If the TNS names are correctly configured, then your connection string might be "DBI:OCI8:the_sid".Codo
I don't have the TNS names configured.Jon Kruger

1 Answers

3
votes

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.