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

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

Related

Oracle SQL Developer Works SQLplus DOESN'T

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

ORA-12154 TNS can't resolve specified identifier

i'm trying to connect to my oracle server using a batch file, but while i try connecting i got the following error:
ORA-12154: TNS: could not resolve the connect identifier specified
I've already check the tnsnames.ora ad the identifier is spelled correctly; i've put in the environment's variable a new variable named TNS_ADMIN that point on my admin folder in the client section.
ty tnsname.ora is as following
ORCL_SRVDATIORIO12 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ORCL)
(SERVER = DEDICATED)
)
)
If i try connecting to that server using SSMA for example, using the tnsnames mode (SID or the description name), connection will establish just fine; while running it in command line it return me the error.
Also if i try running
tnsping <my tnsname>
i'll get:
TNS Ping Utility for 32-bit Windows: Version 12.2.0.1.0 - Production on 03-GEN-2019 14:36:59
Copyright (c) 1997, 2016, Oracle. All rights reserved.
File di parametri utilizzati:
C:\app\client\user\product\12.2.0\client_1\network\admin\sqlnet.ora
TNS-03505: Impossible finding name
So i checked the sqlnet.ora file and the directory path seems fine to me:
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, LDAP)
any suggestion?
EDIT: i solved by simply creating a new text file and copy past the previous contents in the new one.
you need to check tnsnames.ora. tnsnames.ora contains tns names and their connection declarations. You need to use appropriate tns name to connect your database.
tnsping <tns_name> //tns_name is needed to be defined in tnsnames.ora
in your case
tnsping ORCL_SRVDATIORIO12 10
need to return success message. if it does not, it means that your connection decriber is wrong. In which case, you need to talk with your DBA

ORA-12560: TNS: Error protocol Adapter

I would like to export database schema with expdp/impdp. For that reason I am trying to do the same steps like in this tutorial.
when I enter sqlplus / as sysdba in the command line, I will be ased to enter user name and pasword. When I do this and click Enter, the following errors is comming:
ORA-12560: TNS: Error protocol Adapter
I am using windows 7 and have installed oracle 12c. All oracle services are started. I login from cmd.exe as adminstrator
I think I know the problem. You said that you did the same steps in the tutorial.
In the tutorial, he did this step C:>set oracle_sid=db.
Did you have the same name of the Oracle SID ? If you did a default installation, by the default the Oracle SID is orcl .
In your case, do this C:>set oracle_sid=ORCL. To verify the Oracle SID, go to this path C:\oracle\app\oracle\product\11.2.0\server\network\ADMIN and open the listener.ora and check the host name.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST =ORCL)(PORT = 1521)
)
)
)
If you have HOST=ORCL, then you must do this C:>set oracle_sid=ORCL. If you have another name, do this C:>set oracle_sid=NAME_OF_YOUR_HOST
TNS adpater is because you are creating a local uses under orcl, please create a user under pdborcl, this will solve your connectivity problem.

Oracle 10g: Issue with startup mount command (ORA-24324, ORA-01041)

I want to disable the archive logs in my oracle db. But when i shutdown and try to mount the database i am getting the following error.
C:\>sqlplus scott/tiger#ORCL as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 18 10:44:17 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
SQL> startup mount
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
Can any one please help me in resolving this issue.
Edit1:- Listener.ora
# listener.ora Network Configuration File: E:\oracle\product\10.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = E:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = INHOS.dg.server.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
Not sure if this is root cause, but after shutdown and before startup, try exiting and re-entering SQL*Plus.
First edit:
Ok, so, two different problems. The "hostdef extension doesn't exist" error happens when you try to startup from the same SQL*Plus session you shutdown from. Solution is to exit and re-enter SQL*Plus between shutdown and startup.
The ORA-12514 "Listener does not currently know of service requested in connect descriptor" is due to trying to remotely start (your SQL*Plus connect string is scott/tiger#ORCL as sysdba which specifies #ORCL) the instance, and the listener is configured only for dynamic service registration. If your listener is configured only for dynamic service registration, then trying to remotely start the instance will give you an ORA-12514. It's a bit of a catch-22. The problem is, until the instance is started, it can't register with the listener. If it's not registered with the listener, you can't start it up. There are two possible solutions:
You could add a static listener configuration to the listener.ora file and bounce the listener.
You could directly login as the Oracle software owner, to the server that the database is installed on, and set ORACLE_HOME and ORACLE_SID, then connect as / as sysdba.
Hope that helps.
ORA-24324 can mean that the database simply has not been started, and so the resolution would be to
first start the database and listeners (if any)

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