Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SID and Service name; connection problems

I'm trying to connect to oracle db on remote server through sql developer. I copied the connection details to tnsnames and I'm able to connect to the db.

However i have another db application which is same as sqldeveloper and when I try to make a connection, I keep getting this error. This application uses oracle jdbc thin client which requires hostname and SID.

I got the below error:

java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

While troubleshooting, I changed the tns option in sqldeveloper and I have selected basic option to find out what went wrong and I realized that I'm able to connect to it because of the correct service name and not able to connect to the db via SID name even through sqldeveloper.

I have used some db queries to find out SID name but still i keep getting the same error. Please help me troubleshoot.

Thanks for your time..

like image 639
user1751356 Avatar asked Dec 03 '12 21:12

user1751356


People also ask

Is Oracle SID same as service name?

Oracle SID is the unique name that uniquely identifies your instance/database, whereas the Service name is the TNS alias that you give when you remotely connect to your database, and this Service name is recorded in tnsnames.

Can the SID and service name be same?

On the other hand, the SERVICE_NAME is used to register an instance with the listener. In most all cases, Oracle recommends that the value of the service_name be the same as the SID. However, a SERVICE_NAME can point to more than one instance, and the DBA can gen-in additional SID's into a SERVICE_NAME .

How do I find the Oracle SID and service name?

select instance_name from v$instance; will give you SID name. select name from v$database; will give DB NAME. select instance_name from v$instance; will give you SID name.

What is service name in Oracle Connection?

SERVICE_NAMES specifies one or more names by which clients can connect to the instance. The instance registers its service names with the listener. When a client requests a service, the listener determines which instances offer the requested service and routes the client to the appropriate instance.


2 Answers

ORA-12505 means your client passed a SID that the listener on the server end didn't recognize at all.

In 10G and above You can use EZ connect without configuring the server side like this:

sqlplus hr@liverpool:1521/DEMO

hr is the user name
liverpool is the server name
1521 is the port the listener for the DB is listening on
DEMO is the database SID

(OR)

If you still want to use tnsnames.ora, try running tnsping SID from your client.

On LINUX, You can also have ORACLE read a tnsnames.ora file from a local path - just set TNS_ADMIN to the directory where your tnsnames.ora file is.

Otherwise, you need to configure tnsnames.ora in $ORACLE_HOME/network/admin on the client


If you need to know the database SID, use this:

select sys_context('userenv','db_name') from dual;

See this URL:

Checking oracle sid and database name

like image 122
A B Avatar answered Sep 21 '22 12:09

A B


I'm facing this problem too. Linux with oracle 11.2.0.1.

What I found was that the connection string must be:

sqlplus hr@liverpool:1521:DEMO

and not

sqlplus hr@liverpool:1521/DEMO
like image 34
Øyvind Øfsthsu Avatar answered Sep 24 '22 12:09

Øyvind Øfsthsu