Error while connecting to Oracle DB on server - oracle

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.

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

Unabe to resolve cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

I am trying to access an oracle database on another machine. I am using:
Ubuntu Server 18.04
oracle client 12.2
python 3.6 and cx_oracle 6.4.1
I constanly get this error:
Error
File "basic_test.py", line 5, in <module>
con = cx_Oracle.connect('jalabe','jalabepass', cx_Oracle.makedsn('ipserver','port',None,'prod'))
cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
basic_tst.py
import cx_Oracle
# first attempt
# con = cx_Oracle.connect('jalabe/jalabepass#ipaddress/prod')
# second attempt
con = cx_Oracle.connect('jalabe','jalabepass', cx_Oracle.makedsn('ipaddress','port',None,'prod'))
print(con.version)
con.close()
tnsnames.ora
DATABASE.WORLD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ipaddress)(PORT = port))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)
Other info
$ORACLE_HOME as /usr/lib/oracle/12.1/client64/lib/
File tnsnames.ora is inside /usr/lib/oracle/12.1/client64/network/admin
I have read many post without any luck. From all of the post I have read these are the ones I think are more usefull although they haven't work
ORA-12514 TNS:listener does not currently know of service requested in connect descriptor
https://stackoverflow.com/questions/46914943/can-not-connect-ora-12514-tnslistener-does-not-currently-know-of-service-reque
I am sure it might be some character somewhere.
I don't have sqlplus installed nor tnslistener. (Could it be the cause?) (I have read that tnslistener should be in the oracle server which is why i haven't installed it)
Here are a few comments and suggestions to help you correct your issue:
1) Install SQL*Plus and use it to connect to your database. You should be able to connect using the connect string 'jalabe/jalabepass#host/service_name' where 'host' is the host on which the database is found and 'service_name' is the service name of the database you want to connect to. This same connect string should work within cx_Oracle as well. You don't need to use makedsn() or tnsnames.ora (although they should also work, of course!)
2) Do not set the environment variable ORACLE_HOME when using the Instant Client.
3) On the database machine you should be able to run the command 'lsnrctl status' which will show you the status of the listener and which services it knows about. If your service isn't in the list, that's the source of the issue!
4) If you stop and restart the listener it can take a bit of time before the database will register itself with the listener. You can force that to happen more quickly by issuing the command 'alter system register' as SYSDBA in the database (or stopping/starting the database).
Hopefully that helps you out!

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

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)

Resources