简体   繁体   中英

Connection to Oracle Database using JDBC and Python

I am trying to connect my python code to an SQL database, I have an oracle driver and a jdbc database link and this is the code that we have so far but it definitely does not work please help. The first section of code is how we connected the database in java which worked but the second is our python version that doesn't work. We are hosting all our information

Java (connects):

public class PersonDao {
  // ORACLE JDBC Driver
  String driverName = "oracle.jdbc.driver.OracleDriver";
  String connectionURL = "jdbc:oracle:thin: olandon/perry@spring2020.cjjvanphib99.us-west-2.rds.amazonaws.com:3234:ORCL";
      Driver driver;
      Connection connection;

Python (does not connect):

class PersonDao:
    def __init__(self):
      dsn = cx_Oracle.makedsn("spring2020.cjjvanphib99.us-west-2.rds.amazonaws.com", 3234, sid="orcl")
      connection = cx_Oracle.connect("olandon", "perry", dsn, encoding="UTF-8")
      

Could it be your AWS RDS security group? You might need to enable port 3234 in the RDS security group

You can try the command below:

conn = cx_Oracle.connect('username/password@IP:port/server_name')

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