Skip to Content
0
May 14, 2020 at 10:24 PM

Connection to on premise MS SQL Server using Spring Boot and SAP Cloud Connector

369 Views

Hi Experts!

I'm new to the SAP world and this might be a small fix but please bear with me.

I'm tasked with connecting to an on-premise MS SQL Server and retrieve data from it using REST APIs. I've installed MS SQL Server locally and setup SAP Cloud Connector using Non-SAP System as backend type and TCP as protocol. The connection is reachable (Check Status) on SAP CC.

As the next step, I created a simple Spring Boot application. It uses JPA for DB operations. The app consists of a simple GET API which does a simple employeeRespository.findAll() to return the data. I tested the App using localhost DB URL and it worked fine.

Next, I changed the DB URL to Virtual Host URL (as per SAP CC), did ‘mvn clean package’ to create the war file and deployed it on SAP Cloud Platform as Java Application using Tomcat 8 server.

I'm getting the following error on Default Trace:

2020 05 14 22:18:13#+00#ERROR#org.apache.tomcat.jdbc.pool.ConnectionPool##anonymous#localhost-startStop-1#na#ede76a891#employeefetchadapter0#web##na#na#na#na#Unable to create initial connections of pool. com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host virtualhost, port 51651 has failed. Error: "vistualhost. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)

From my understanding, it seems like my Spring Boot app is not being able to resolve the database URL I provided in applications.properties file. Before generating the war file I changed the datasource url from 'localhost:51651' to 'virtualhost:51651' (as per the name on SAP CC). I have allowed remote access to the MS SQL Server and allowed all TCP/UDP ports on the Firewall for inbound requests.

I'm not sure how SAP CP connects to SAP CC database connections.

Any help to resolve this issue or a workaround is much appreciated. Thank you!