Claude
Claude

Reputation: 23

Camunda server starting and cannot initiate jdbc connection (oracle DB)

I have a jdbc connection to a oracle DB;

if(connection == null || connection.isClosed()) {
    try {
        connection = null;
        connection = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/ORCL", "usr", "pass");
} catch(Exception e) {
    e.printStackTrace();
    throw e;
}

When the Camunda server starts and tries to get the connection it throws:

java.sql.SQLRecoverableException: IO Error: Invalid number format for port number at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:774) at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source)

Even tho in the Expressions tab (eclispe) it shows me that it can get the connection... but when i go over the DriverManager in debugger it throws the error and the connection is null... Can anybody help me?

I have the ojdc driver in the server and the classpath i use ojdc8 and i use the exact same connection on a SpringBoot app and it works without any problems;

Thanks!

Upvotes: 2

Views: 685

Answers (1)

Claude
Claude

Reputation: 23

Problem solved!

You need to get the jdbc driver class through reflection first, when i start the SpringBoot app Spring automatically creates the class

  if(connection == null || connection.isClosed()) {
        try {
            connection = null;
            Class.forName("oracle.jdbc.driver.OracleDriver");
            connection = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/ORCL","usr","pass");
        }
        catch(Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
    return connection;

Upvotes: 0

Related Questions