Oracle SQL Developer Works SQLplus DOESN'T - oracle

With Oracle SQL-Developer I'm able to connect to my VMware CentOS 7 Oracle database ORCL.
if I try to connect with SQLPlus I'm told the realm doesn't exist.
Any idea as to why I can connect with Oracle SQL-Developer and not SQLPlus on the same machine?
TNSPing resolves the SID/Service name without any problems.
C:\oracle\ora11g\11.2.0.2\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = 192.168.1.50) (Port = 1521))) (CONNECT_DATA = (SERVICE_NAME = ORCL)))
OK (10 msec)
Here's the output from the SQLPlus connection attempt from the same machine that SQL-Developer is working without any issues.
C:\oracle\ora11g\11.2.0.2\BIN>sqlplus system/password#orcl
SQL*Plus: Release 11.2.0.2.0 Production on Wed Jul 3 08:31:13 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3640
Additional information: -2140813497
Process ID: 0
Session ID: 0 Serial number: 0

Your sqlplus command, try this:
sqlplus user/password#192.168.1.50:1521/ORCL
In SQL Developer, once you're connected, run this:
show tns
show connection
Make sure you're actually trying to connect to the same database in SQLPlus, also make sure your $ORACLE_HOME and $ORACLE_SID are properly configured.

This looks like something is wrong with Oracle_Home or your listener.
Could you please - - LSNRCTL and check the status of the same.
If it is fine, then try to connect to sys:
sqlplus /nolog
conn / as sysdba

Related

Oracle Personal Edition 21c: Listener cannot find service name

I'm getting started with Oracle Personal Edition. Installation was successful. Trying to connect to the database and getting stuck. I have:
tnsping xe2
TNS Ping Utility for 64-bit Windows: Version 21.0.0.0.0 - Production on 16-APR-2022 17:14:25
Copyright (c) 1997, 2021, Oracle. All rights reserved.
Used parameter files:
C:\app\geral\product\21c\homes\OraDB21Home1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.docker.internal)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XEPDB1)))
OK (10 msec)
which seems promising. In sqlplus I can:
sqlplus / as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Sat Apr 16 17:14:40 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
then show the pdbs:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 XEPDB1 READ WRITE NO
SQL>
So, I now want to try to connect to the CON_NAME XEPDB1 using that TNS entry I tested:
SQL> conn foo#xe2
Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Warning: You are no longer connected to ORACLE.
At this point, I'm stuck. How do I troubleshoot and resolve the cause of the error message?
Your listener is on and working but your instance has not dynamically registered it’s services with it nor are they statically part of your listener config.
Easiest option is to get your instance to register itself. Look at the instance parameter local_listener, this needs to point to your listener running on (HOST = host.docker.internal)(PORT = 1521), you can do this with a tnsname that points to the same listener or you can take advantage of EZConnect syntax and just use the host name (the default port is 1521 anyway). I would recommend setting up a tnsnames entry just called listener which contains the host and port but no connect_data.
(Using EZconnect)
Alter system set local_listener='host.docker.internal';
This will self-validate .
You then just need to wait for automatic registration to occur, you can see this happening in your listener logs, you can trigger it manually with alter system register; and you can confirm it’s happened by looking at the results of lsnrctl status host.docker.internal.

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-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

Unable to connect with SQLPlus, but it works with SQL Developer

Windows 7, Oracle 11.2.0.1; it used to be working fine, not sure what happened lately. But I am not able to connect to SQL plus using sqlplus, and entering user name and password.
SQL Developer is working fine. Also the following command is working fine:
sqlplus system/system#//localhost:1521/ORACUSTOM
Though the above command is working fine, some of the scripts are not working (as these scripts try to connect to a different database. So I need to make the following work:
$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 10 19:35:34 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter user-name: system
Enter password:
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
I'd appreciate if you can explain why one approach is working and the other is not.
The jdbc connection string
sqlplus system/system#//localhost:1521/ORACUSTOM
indicates that the service name 'ORACUSTOM' is used as the service name. Check the tnsnames.ora file for the right TNS name & ensure that it uses 'Oracustom' as the service name
In your case the TNS name should be something like
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = localhost)(Port = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = oracustom)
)
)
With this entry in tnsnames.ora, you'll have to enter system#orcl as the username
(PS: Don't login as system. Bad idea.)

Error while connecting to Oracle DB on server

I am getting an error while trying to connect to oracle DB on the server throught Toad. The error message is :
ORA-12514: TNS:listener could not resolve Service_Name given in connect descriptor.
Everything was working fine till yesterday but today my server got restarted and i am not ablt to connect to DB. I tried tnsping as well and it is working fine:
TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0 - Production on 10-NOV-20
10 15:13:29
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
c:\oracle\ora92\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = MY4D) (PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =sim)))
OK (80 msec)
I did lsnrctl start and it says Service OracleOraHome92TNSListener already running.
Still oracle throught toad is not working. Can anyone help me in solving this.
This error usually happens when your oracle services are not running. You will see the services by names "Oracle..TNSListener" and another service with name "OracleServicesim" in your services.msc. Check if both of them are running, or restart both those services. Then try to connect. It should work fine.

Resources