Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to do a sanity testing of newly installed Oracle client 12.2 in RHEL 7 linux from a Python program, but it fails with the above error, not sure what I am missing on there. Please help with this case :

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

my tnsnames.ora file under /home directory

  FRDLD2D1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(Host = frdld2d1.de.db.com)(Port = 1825))
    )
    (CONNECT_DATA =
      (SID = FRDLD2D1)
      )
   )

and my python program goes below

#!/usr/bin/python
import cx_Oracle
#connection = cx_Oracle.connect('PNTH_LOGGINGB_OWNER/password')
connection = cx_Oracle.connect('PNTH_LOGGINGB_OWNER/[email protected]:1825/orcl')
cursor = connection.cursor()
querystring = "select * from BDR_JOB_MASTER_LOG where ROWNUM <= 1;"
cursor.execute(querystring)

frdld2d1.de.db.com - IP address : 10.245.63.34

Appreciate if any points the glitch on here.

tnsping utility is not there to test since it is an instaclient version

oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm.

But with SQLPlus, I am able to connect the database without any issues.

like image 688
Vijay Avatar asked Oct 29 '17 21:10

Vijay


People also ask

How do I fix ORA 12514 TNS listener does not currently know of service requested in connect descriptor?

Action: Wait a moment and try to connect a second time. Check which services are currently known by the listener by executing: lsnrctl services. Check that the SERVICE_NAME parameter in the connect descriptor of the net service name used specifies a service known by the listener.

How do I fix TNS listener error?

First check the tnsnames. ora file and ensure that it points to the correct server and port. If the Forms server is on another machine, test the TNS resolve with tnsping from the command prompt. Finally, check the listener.

How do you fix ORA 12505 TNS listener does not currently know of SID given in connect descriptor?

Your first action to resolve this issue should be to wait a few seconds, then try to re-connect to the database again. If this attempt is unsuccessful, try checking to see which instances are known by the listener. To do this, execute: lsnrctl services <listener name>. You can also check the status of the listener.


Video Answer


1 Answers

Please use this as your connection string :

connection = cx_Oracle.connect('PNTH_LOGGINGB_OWNER', 'hdgf_76trf', 
                                cx_Oracle.makedsn('10.245.63.34',1825,'FRDLD2D1') );

Changing SID = FRDLD2D1 to SERVICE_NAME = FRDLD2D1 in your TNSNAMES.ORA file may be an alternative.

like image 116
Barbaros Özhan Avatar answered Oct 05 '22 23:10

Barbaros Özhan