SAP Connector using Oracle JDBC and virtual host name "oracle" gives: Failed to obtain JDBC Connection: DataSource returned null from getConnection():

276 views Asked by At

Using a working JDBC connect string for a connect to a remote Oracle database using Oracle JDBC like

jdbc:oracle:thin:@myremotehost:1521:mysid

and mapping it inside SAP Connector with nomenclature

jdbc:oracle:thin:@<virtual host name>:<virtual Port>:mysid

with

<virtual host name> = oracle
<virtual Port>= 61521

resulting in

jdbc:oracle:thin:@oracle:61521:mysid

will end up with error

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: DataSource returned null from getConnection(): org.ops4j.pax.jdbc.impl.DriverDataSource@45d186af

To check if the issue is related to a problem in the Oracle JDBC Driver we

  1. Installed SAP JDK 8 on the remote database machine

  2. Using Maven to create a standalone Spring-Boot/Spring-JDBC/HikariCP/Oracle JDBC JAR reflecting the stack of SAP Connector / SAP VM using with iFlows

  3. Tested the JAR with connect string successfully

    jdbc:oracle:thin:@myremotehost:1521:mysid
    
  4. add on remote database machine to file /etc/hosts an entry like

    oracle   XXX.XXX.XXX.XXX
    

    where XXX.XXX.XXX.XXX is the IP of machine "myremotehost"

  5. Tested the recreated JAR with new connect string successfully

    jdbc:oracle:thin:@oracle:1521:mysid
    
  6. Replacing "oracle" as virtual host name by "myoracle" like below fixed the issue with SAP Connector

    jdbc:oracle:thin:@myoracle:61521:mysid
    

According to our finding we think the error is caused inside SAP Connector using Java String.replace() function replacing inside connect string

jdbc:oracle:thin:@oracle:61521:mysid
  • Any occurance of "oracle" (virtual host name) by the remote host name "myremotehost"
  • Any occurance of "61521" (virtual port number) by the remote host port "1521"

ending up with a connect string like

jdbc:myremotehost:thin:@myremotehost:1521:mysid

which is invalid because the first occurrence of "oracle" in original connect string is required to resolve classes giving the seen error because no connection could be established.

For Developers of the SAP Connector at SAP: Valid workaround in the Java code of SAP Connector would be using regexp or restrict replacement for substring right of at-Sign "@" in connect string so that class resolving is still possible ;-)

kind regards Frank Scherie

Expectation:

SAP fixes the issue and creates a bug/note for the issue

0

There are 0 answers