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

三世轮回 提交于 2019-12-06 05:48:52

问题


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/password@10.245.63.34: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.


回答1:


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 SERVICE_NAME = FRDLD2D1 to SID = FRDLD2D1 in your TNSNAMES.ORA file may be an alternative.



来源:https://stackoverflow.com/questions/47005505/cx-oracle-databaseerror-ora-12514-tnslistener-does-not-currently-know-of-serv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!