How to connect to oracle from SQL Developer - oracle

I have problem with connecting to Oracle from Sql developer. When I try this connection settings. it returns error from printscreen:
when I tried tns ping, it returns to me
C:\Windows\system32>tnsping XE
TNS Ping Utility for 64-bit Windows: Version 18.0.0.0.0 - Production on 09-APR-2021 23:47:25
Copyright (c) 1997, 2018, Oracle. All rights reserved.
Used parameter files:
C:\app\Uzivatel\product\18.0.0\dbhomeXE\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK (0 msec)
Can someone give me a point what I doing wrong? Thanks for help.
l
snrctl status is C:\Windows\system32> lsnrctl status
LSNRCTL for 64-bit Windows: Version 18.0.0.0.0 - Production on 09-APR-2021 23:57:42
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 18.0.0.0.0 - Production
Start Date 09-APR-2021 23:09:50
Uptime 0 days 0 hr. 47 min. 52 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File C:\app\Uzivatel\product\18.0.0\dbhomeXE\network\admin\listener.ora
Listener Log File C:\app\Uzivatel\product\18.0.0\diag\tnslsnr\PoŔÝtaŔ\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
When I tryed to change to Sid, it returns me:
when I try to
C:\Windows\system32>lsnrctl reload
LSNRCTL for 64-bit Windows: Version 18.0.0.0.0 - Production on 10-APR-2021 00:10:54
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
64-bit Windows Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
The command completed successfully
But problem is still same:
I tried lsnrctl status and It return to me
C:\Users\Uzivatel>lsnrctl status
LSNRCTL for 64-bit Windows: Version 18.0.0.0.0 - Production on 10-APR-2021 02:01:20
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 18.0.0.0.0 - Production
Start Date 10-APR-2021 00:44:34
Uptime 0 days 1 hr. 16 min. 45 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File C:\app\Uzivatel\product\18.0.0\dbhomeXE\network\admin\listener.ora
Listener Log File C:\app\Uzivatel\product\18.0.0\diag\tnslsnr\PoŔÝtaŔ\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PoŔÝtaŔ)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "xe", status BLOCKED, has 1 handler(s) for this service...
Service "XE" has 1 instance(s).
Instance "XE", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
it seems that there is some problem, isnt it?

UPDATE
I wrongly supposed your Database was running.
Start your database by issuing a startup
CMD> sqlplus /as sysdba
SQL> startup
Before attempting to connect, check your listener with lsnrctl status you should now see the XE service there.
If everything's in place, you should then be able to connect.
As far as I can see, there's no service named XE
You can either connect by selecting SID instead of SERVICE NAME
Or try to add a static registration to your listener.ora
LISTENER =
(DESCRIPTION_LIST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
  )
)
SID_LIST_LISTENER=
(SID_LIST =
   (SID_DESC=
     (SID_NAME=XE)
     (SERVICE_NAME=XE)
     (ORACLE_HOME=C:\app\Uzivatel\product\18.0.0\dbhomeXE)
   )
)
Reload the listener
lsnrctl reload
And then try to connect via SQL Developer, using the SERVICE NAME
Another thing you can try, is getting inside the Database and issue a
alter system register;
To see if the database register against the listener by itself.

Are you sure that "XE" is your services name??
Try selecting SID and set a name to the connection

Related

Can not connect to the Oracle Service

I would like to connect to the running "orcl" Oracle database.
I don't have much experience on the Oracle administrator. I installed Oracle 12c in a Windows Server, as I see the "Oracle", "OracleOraDB12Home1TNSListener" and "OracleServiceORCL" services are started in the machine.
I added the following to the "tnsnames.ora" file:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1539))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
I get "Ok" result from executing the "tnsping orcl" command.
I can login with "sqlplus / as sysdba" and when I query with "select name from v$database" command, I see "orcl" database is active.
But when I try to connect to the "orcl" database using Sqldeveloper, or when I execute
"sqlplus -L "system/password#(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1539))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = orcl)))"
I hit the issue below:
SQL*Plus: Release 12.2.0.1.0 Production on Thu Aug 1 10:53:28 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
When executing the "lsnrctl status" command:
LSNRCTL for 64-bit Windows: Version 12.2.0.1.0 - Production on 01-AUG-2019 12:16
:04
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.2.0.1.0 - Produ
ction
Start Date 01-AUG-2019 09:38:59
Uptime 0 days 2 hr. 37 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\Administrator\virtual\product\12.2.0\dbhome_1\n
etwork\admin\listener.ora
Listener Log File C:\app\Administrator\virtual\diag\tnslsnr\WIN-91FKK175
962\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-91FKK175962)(PORT=1539)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521_1ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
How can I connect to the orcl database? What I am missing in configuration or anywhere?
i think what you want is just
sqlplus [user]/[Password]#[connect identifier]
eg. your user is system, Password is pswd and connect identifier in your example is 'ORCL'
so your sqlplus command would be:
sqlplus system/pswd#orcl
if you DB is installed on your local machine that it should be also be possible just to conect to localhost instead of service
sqlplus system/pswd#localhost

ORA-12505, TNS:listener does not currently know of SID given in connect

I'm using JDeveloper when I try to create a database connection with the hr/hr user I get this message:
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:ORCL
then I go to the command line and I put tnsping ORCL
C:\Users\Administrator>tnsping ORCL
TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 20-FEB-2
018 15:55:23
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
C:\app\oracle\virtual\product\12.2.0\dbhome_1\network\admin\sqlnet.ora
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO
COL=TCP)(HOST=213.130.77.281)(PORT=1521)))
OK (90 msec)
C:\Users\Administrator>é2#
and checking If the Oracle listener is running:
C:\Users\Administrator>lsnrctl status
LSNRCTL for 64-bit Windows: Version 12.2.0.1.0 - Production on 22-FEB-2018 12:34
:05
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TESTINFRA)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.2.0.1.0 - Produ
ction
Start Date 20-FEB-2018 15:02:35
Uptime 1 days 21 hr. 31 min. 34 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\oracle\virtual\product\12.2.0\dbhome_1\network\
admin\listener.ora
Listener Log File C:\app\oracle\virtual\diag\tnslsnr\TESTINFRA\listener\
alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TESTINFRA)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
Your listener service doesn't clearly state that it has any ORCL database SID here, on this host.
When you used TNSPING command to check connectivity, you walked around this by using Oracle EZCONNECT adapter that resolves all needed connect info itself, but JDBC driver needs either clear declaration of SID in listener or clear command to use EZCONNECT adapter.
So are two ways to solve this:
Open listener.ora and find these lines:
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle\virtual\product\12.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\virtual\product\12.2.0\dbhome_1\bin\oraclr11.dll")
)
)
Replace them with these:
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle\virtual\product\12.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\virtual\product\12.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = ORCL)
(ORACLE_HOME = C:\app\oracle\virtual\product\12.2.0\dbhome_1)
(GLOBAL_DBNAME = ORCL)
)
)
Then use "lsnrctl stop" and "lsnrctl start" to restart the listener. This change will register new SID_DESC block with description of your database SID in listener.
Change JDBC string to connect through EZCONNECT adapter and not through SID. Please, post your JDBC connection string if you want exact answers, but in overall you shouldn't use:
jdbc:oracle:thin:#213.130.77.281:1521:orcl
And use instead:
jdbc:oracle:thin:#//213.130.77.281:1521/orcl
This change will tell JDBC to use EZCONNECT adapter.
In you jdbc error you are using : localhost:1521:ORCL
In the TNSPING, it’s 213.130.77.281
Use the ip address in jdev also.

Cannot connect to oracle pluggable database

Iinstalled oracle in my Windows 10 64 bit pc and I started doing verification steps mentioned in the tutorial which's given in the oracle website which can be found in the link below.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/Windows_DB_Install_OBE/Installing_Oracle_Db12c_Windows.html
When I try to connect to my pluggable database using this command
C:\Users\Chathura>sqlplus sys/Oracle_1#orclpdb as sysdba;
it gives me following message
SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 30 19:34:25 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Enter user-name:
But when I try to connect to container database it connects successfully.
This is how I created pluggable database.
I read articles regarding this tried adding TNS_ADMIN system variable too, but non of those worked.
What I am doing wrong here?
You have to use the service name for your pluggable, you can't use the SID..that's only going to work for the container.
So find out the service name
[oracle#vbgeneric ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 30-JAN-2018 10:05:02
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 25-JAN-2018 12:14:50
Uptime 4 days 21 hr. 50 min. 12 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service orcl12c
Listener Parameter File /u01/app/oracle/product/12.2/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/vbgeneric/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vbgeneric)(PORT=8081))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "49b6c41a4c152576e0530100007feda7" has 1 instance(s).
Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "4bb765ec28ff1109e0530100007f49e5" has 1 instance(s).
Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "app_con" has 1 instance(s).
Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl12c" has 2 instance(s).
Instance "orcl12c", status UNKNOWN, has 1 handler(s) for this service...
Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl12cXDB" has 1 instance(s).
Instance "orcl12c", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle#vbgeneric ~]$
Then connect, use #servicename vs #SID
in my case that's #orcl
Or connect to your container, then switch over to your PDB
oracle#vbgeneric oracle]$ sqlplus sys/oracle#orcl12c as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 30 10:09:28 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> ALTER SESSION SET container = orcl;
Session altered.
SQL>
Tim talks about this here.
connect to your database ( pluggable database) and make thing configuration
`
startup mount;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
`
and also that
`
update sys.props$ set VALUE$='WE8MSWIN1252' where NAME='NLS_CHARACTERSET';
commit;
shutdown immediate;
startup;
`
after that just check your tnsnames.ora`enter code here`
WINDOWS 10:
Don't know if this is exactly your problem, but I got one very similar. After creating new users to PDB, I couldn't connect to Database. Here is what I did (don't know if you need all of this, but it worked for me).
Try this options on SQL Dev Connection:
connection
On $ORACLE_HOME/network/admin add:
ORCLPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb)
)
)
On network/admin/sqlnet.ora file add:
SQLNET.ALLOWED_LOGON_VERSION_CLIENT = 8
SQLNET.ALLOWED_LOGON_VERSION_SERVER = 8

ORA-12514 TNS:listener does not currently know of service requested in connect descriptor for existing service

I know that this is a pretty popular problem, and I had run into it several times before but were able to resolve it but not this time.
I had made sure that I'm using the correct service name by running
SQL> select value from v$parameter where name='service_names';
VALUE
--------------------------------------------------------------------------------
XE
My tnsnames.ora has the XE service name:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
When I start the listener, it appear to recognize the service:
[root#aa-axm admin]# lsnrctl start
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 09-OCT-2015 12:58:28
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/11.2.0/xe/log/diag/tnslsnr/aa-axm/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)) (SERVICE_NAME=XE))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(SERVICE_NAME=XE))
Connecting to (DESCRIPTION=(SERVICE_NAME=XE)(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 09-OCT-2015 12:58:28
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/11.2.0/xe/log/diag/tnslsnr/aa-axm/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE))(SERVICE_NAME=XE))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(SERVICE_NAME=XE))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
And yet, I'm still getting that blasted error
[root#aa-axm admin]# sqlplus SYSTEM/**********#XE
SQL*Plus: Release 11.2.0.2.0 Production on Fri Oct 9 12:58:36 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
What am I missing? TIA
I had it finally resolved by doing
alter system set local_listener='XE' scope=both;
alter system register;
thanks to Alex Poole for setting me on the right path.

ORA-12545 : Oracle SID Suddenly Stopped working

I have a baffling problem. I have an Oracle 11g set up on Linux that was working fine. I was able to connect remotely from other machines using a SID based connection string such as
sqlplus myschema#192.168.184.102:1521:orcl
then for some inexplicable reason it stopped working. I'm not sure what I or someone else jiggled loose.
now i'm only able to connect remotely using a SERVICE_NAME or TNSNAME based methods
sqlplus myschema#192.168.184.102:1521/orcl
sqlplus myschema#ORCL
Both work and this would be fine and well, but I have applications that rely on SID connection pattern that I can change. Could some kind soul help me figure out what I'm missing
Below is my configuration:
LISTENER.ORA:
[oracle#dbora112 ~]$ cat /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = dbora112)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/u01/app/oracle
LISTENER STATUS:
[oracle#dbora112 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-MAR-2015 14:50:05
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 04-MAR-2015 14:37:12
Uptime 0 days 0 hr. 12 min. 52 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /opt/u01/app/oracle/diag/tnslsnr/dbora112/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbora112)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
TNSNAMES.ORA:
[oracle#dbora112 ~]$ cat /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.184.102)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = orcl)
)
)
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.184.102)(PORT = 1521))
SQLNET:
[oracle#dbora112 ~]$ cat /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
# sqlnet.ora Network Configuration File: /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
ADR_BASE = /opt/u01/app/oracle
Can connect with not problem using TNS
[oracle#dbora112 ~]$ sqlplus schema/xxx#ORCL
SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 4 14:54:10 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Can connect with no problem using Service Name
[oracle#dbora112 ~]$ sqlplus schema/xxx#192.168.184.102/ORCL
SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 4 14:55:52 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Cannnot connect with SID
[oracle#dbora112 ~]$ sqlplus schema/xxx#192.168.184.102:orcl
SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 4 14:56:38 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-12545: Connect failed because target host or object does not exist
Database Instance (SID)
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl
Since you can connect with your TNS alias, and that is using the SID in the connection description, the SID is working.
But your EasyConnect string is incorrect. From the SQL*Plus documentation:
The easy or abbreviated connection identifier has the syntax:
[//]host[:port][/service_name]
You cannot use the SID with Easy Connect, only the service name; so your connect using:
sqlplus schema/xxx#192.168.184.102:orcl
or even
sqlplus schema/xxx#192.168.184.102:1521:orcl
... can never have worked. You can use that form with a JDBC URL using the older style:
jdbc:oracle:thin:#192.168.184.102:1521:orcl
... but that is not the same thing as an SQL*Plus connection, despite looking similar.
If you're trying to check if a JDBC connection of that form will work, you cannot do so with SQL*Plus, but your TNS alias check is verifying it is set up as you expect anyway - as long as it uses the same host, port and SID. It would probably be better to use the newer JDBC syntax, but from the question it sounds like you can't change that.
Read more about Easy Connect.
This could be when Oracle cannot resolve the hostname to IP. Can you resolve your hostname with nslookup? I.e.,
nslookup yourhostname
Also make sure reverse lookup is working:
nslookup yourIpAddr

Resources