简体   繁体   中英

cx_Oracle Connection Timeout

I am trying to connect to Oracle database but getting below error:

curcon = cx_Oracle.connect(conn_str) cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred

Here's block of code:

conn_str = u'user/pwd@111.22.33.444:8000/service'
curcon = cx_Oracle.connect(conn_str) 
cursor = curcon.cursor()

I tried solutions from these two threads but none of them works:

Set database connection timeout in Python

ORA-12170: TNS:Connect timeout occurred

If the error is occurring because of a slow network or system, you may fix the error by reconfiguring the following parameter in sqlnet.ora to larger values:

SQLNET.INBOUND_CONNECT_TIMEOUT = 0

Your sqlnet.ora file can be found in your $ORACLE_HOME/network/admin directory.

I am trying to connect to Oracle database but getting below error:

curcon = cx_Oracle.connect(conn_str) cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred

Here's block of code:

conn_str = u'user/pwd@111.22.33.444:8000/service'
curcon = cx_Oracle.connect(conn_str) 
cursor = curcon.cursor()

I tried solutions from these two threads but none of them works:

Set database connection timeout in Python

ORA-12170: TNS:Connect timeout occurred

Your code works for database on the same machine, this should work for you,

connection = cx_Oracle.connect('user', 'pwd', cx_Oracle.makedsn( 'ip', 'port',None,'given service name/id')) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM