javajdbcsap-cloud-platform

SAP DBTech JDBC: Cannot connect to jdbc:sap://... on SCP


I'm running a Java application in the SAP Cloud Platform that connects to a shared HANA database using JDBC. Out of a sudden (no code changes, no deployments, no config changes...) the application can no longer connect to the database. The logs/stacktrace says:

Failed to get connection from datasource com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: Cannot connect to jdbc:sap://xxxx.od.sap.biz:30015/ [Cannot connect to host xxxxx.od.sap.biz:30015 [Connection refused (Connection refused) (local port 54468 to address 0.0.0.0, remote port 30015 to address xx.yyy.zzz.250 (xxxxx.od.sap.biz))], -813.]. at com.sap.db.jdbc.exceptions.SQLExceptionSapDB._newInstance(SQLExceptionSapDB.java:126) ... at com.sap.db.jdbc.DriverSapDB.connect(DriverSapDB.java:1223)

There is a SAP note: 2501339 - Error: "SAP DBTech JDBC: Cannot connect to jdbc..." occurs when connecting tenant DB by using JDBC driver which suggests to change a port in the connection settings.

I never set any port manually and the described steps in proposed solution do not apply to my problem except for the same error message.


Solution

  • The problem could be resolved by deleting and recreating the existing Data Source Binding for my application in the SAP Cloud Platform Cockpit; available under the "Configuration" menu item. I couldn't specify any port there (and never did) but deleting and recreating it with the same name somehow seemed to solve the problem under the hood.

    (I restarted the application after recreating the binding. Not sure if this was necessary though.)