user3390299
user3390299

Reputation: 83

How to find Oracle database connection details

I am new to Oracle DB and have created a new Oracle 12c database. I am creating a new connection through SQLDeveloper and where can I get the connection details? HostName? Port? SID?

I tried connecting using default details given in documentation but got the below error

Test failed: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor>

Upvotes: 2

Views: 24580

Answers (3)

nikhil kekan
nikhil kekan

Reputation: 532

If you have installed it on same machine on which you are running sql-developer then host: 127.0.0.1 port: 1521 username and password same as you put while installing oracle datatabse. keep sid blank

Upvotes: 1

TenG
TenG

Reputation: 4004

On Windows ISTR, to get the SID, look at the running processes and you should see something called "oracleXXX.exe" or similar. The XXX will be your SID.

You should also see a "TNS" or "Listener" process, probably with the same "XXX".

To get the port number, (usually 1521-1526), find the folder where Oracle was installed to "the "Oracle Home") and in there go to the "network\admin" folder. You should see a "listener.ora" file in there, and if you view this is notepad you should be able to figure out what the port is set to.

This file should also tell you what host/network address the listener is attaching to - you use this IP as the "Hostname" in you connection. Sometimes (again I'm a bit cloudy with Oracle on Windows) the listener.ora might be named listnereXXX.ora, with XXX matching the value you will have seen in SID the checks above.

Obviously if you are new to Oracle, do not amend these files.

If you have netstat/wireshark or similar you can see what the port is attached to the TNS/Listener process.

Upvotes: 1

Panayiotis Savva
Panayiotis Savva

Reputation: 131

You really need to give more info if you need help :) What Server are you using? Linux? Windows?

  • Post your oratab file (/etc/oratab)
  • Post your TNS file ($ORACLE_HOME/network/admin/tnsnames.ora)
  • Post your Listener file ($ORACLE_HOME/network/admin/listener.ora)

Assuming you're using Linux :D

You need to look at the file "/etc/oratab" if you're on Linux. This will contain your SID.

Your TNS (located in $ORACLE_HOME/network/admin/) should contain the TNS Entry with SID as per your oratab file.

This is an example entry you will find in the oratab file: orcl:/opt/oracle/product/10.2.0/db_1:Y

The let hand side "orcl" is your SID, and you will use this for your SID in the Oracle TNS.

If you find that your TNS is configured correctly, then the error message you provided may also indicate that your Database was not registered to the Listener.

You may connect to the sql database as follows: Set your Oracle Environment

$ . oraenv Prompts for SID: Enter the value "orcl" (if this is your SID?) now login: $ sqlplus / as sysdba

This will log you into oracle as a sysdba.

Execute the follwing:

SQL> Alter System Register; You should notice a confirmation message that the system is altered.

now exit SQLplus, and try again

SQL> exit

Upvotes: 2

Related Questions