I am trying to connect to oracle DB using the below program and somehow I am getting the error. I tried to turn off the firewall and check there is no luck. I did check the port number from the tnsnames.ora file for that connection and I am using the same one. I am using the IPv4 address by checking on ipconfig from command prompt. Any help would be greatly appreciated.
There is a problem with Oracle DPY-6005: cannot connect to database. Connection failed with "[WinError 10061] No connection could be made because the target machine actively refused it"
import oracledb
# Create a table in Oracle database
try:
print("############")
#con = oracledb.connect('userid/password@XXX.XXX.XXX.XXX/ORCL')
con = oracledb.connect(user="userid", password='password',
host="XXX.XXX.XXX.XXX", port=1521, service_name="orcl.lan")
print("############")
print(con.version)
# Now execute the sqlquery
cursor = con.cursor()
# Creating a table employee
cursor.execute("create table employee(empid integer primary key, name varchar2(30), salary number(10, 2))")
print("Table Created successfully")
except oracledb.DatabaseError as e:
print("There is a problem with Oracle", e)
# by writing finally if any error occurs
# then also we can close the all database operation
finally:
if cursor:
cursor.close()
if con:
con.close()