Sujit Dhamale
Sujit Dhamale

Reputation: 1446

oracle connection string or host name , port number and TNS

i install Oracle on my machine from ORACLE website

after installation i am able to log in using below command "sqlplus / as sysdba"

enter image description here

a able able to log in using "sqlplus system/"Password" as well

question : i want to connect database using third party tool like SQL developer , how i will get TNS or Host name and port number ?

Upvotes: 0

Views: 4874

Answers (1)

Saiprasad Bane
Saiprasad Bane

Reputation: 487

This is a classic problem one runs when the database is started but listener service isn't. Nothing to worry, below command can help you to check if your listener is active.

lsnrctl status

If this says, listener is not listening add below 2 .ora files and restart Listener.

$ORACLE_HOME/network/admin/listener.ora
$ORACLE_HOME/network/admin/tnsnames.ora

Listener Commands

    lsnrctl start
    lsnrctl stop
    lsnrctl status

Also pasting sample .ora files to make your job easier.

listener.ora

LISTENER =
  (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
       (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))

SID_LIST_LISTENER=
  (SID_LIST=
      (SID_DESC=
         (GLOBAL_DBNAME=dev)
         (SID_NAME=dev)
         (ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1)
                      #PRESPAWN CONFIG
        (PRESPAWN_MAX=20)
        (PRESPAWN_LIST=
          (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
        )
       )
      )

tnsnames.ora

dev=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = dev)
    )
  )

Please ensure you make appropriate changes to GLOBAL_DBNAME, SID_NAME, ORACLE_HOME & SERVICE_NAME in both of the above files. Also if you wish to make this database available over your network, get the HOST parameter configured as your machine IP instead of localhost.

Upvotes: 1

Related Questions