Skip to Content

How to connect SAPUI5 application to SQL Server Database ?

In our SAPUI5 application we need to connect to SQL Server Database 2012 and ECC.We deploy our SAPUI5 applications as BSP applications.

To access ECC data we are using ODATA services.Connecting to SQL Server database from SAPUI5 application is new to us.

So we created a SAPUI5 POC. I created a button. On click of this button, in the controller, I am using a Ajax call to the servlet to connect to the database and pull the data. This is deployed on local tomcat server and this works fine.

Problem is when i deploy this SAPUI5 application as a bsp application. I am getting "404 - Not Found Error". Please suggest.

In Web.xml

<servlet> <description></description> <display-name>HelloWorldTest</display-name> <servlet-name>HelloWorldTest</servlet-name> <servlet-class>com.helloworld.servlets.HelloWorldTest</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloWorldTest</servlet-name> <url-pattern>/HelloWorldTest</url-pattern> </servlet-mapping>

In Controller.

clickTheButton : function() { $.get('HelloWorldTest', {}, function(responseText) {

alert(responseText); $('#jqueryajaxGetUserServletResponse').text(responseText); }); }

Please help me out with this. Also suggest what is the best approach to connect to a SQL Server database from SAPUI5 application.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Mar 22, 2017 at 02:46 PM

    Hi Sravan,

    I know of two options, there can many other options also.

    1) The reason you are getting 404 error is due SAP server is unable resolve the your SQL database IP ( I assume that this database is not your SAP database). Reason is when you deploy UI5 application it sits in your SAP server. to resolve the it , you need see that your SQL server pings from SAP server from os level and vice versa. If this is a production system then it is not that secure.

    2) Second option, Make your SQL server as secondary database(your basis team can help you). Then you can implement your application logic using Odata framework. rest everything remains same as your odata ui5 development. This lot more secure and you will have better control.

    Thanking you


    Add comment
    10|10000 characters needed characters exceeded

  • Mar 22, 2017 at 03:23 PM

    you have to give full url for that ajax call and you have to enable cors if not the ajax call will fail.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 23, 2017 at 03:16 AM

    Hello Sravan,

    The issue this wont work is because your servlet is a java application and your tomcat is a basically a Java application server and it works. The moment you transfer the application to abap server , and it cannot run abap application and hence this error. It is a different case if you move to HCP which can run html and java applications .

    Now let us come to the case of accessing the external Database from Abap -

    1. You can use this link as a reference -External DB . With this you can call an OData service on ABAP which internally retrieves the data from External DB.
    2. Another approach would be to host a servlet on another java server and now access the servlet from Abap using http connection.

    You can compare the 2 options . They would on the factors like use of 2 servers vs just a single abap server.

    Thanks and Regards,


    Add comment
    10|10000 characters needed characters exceeded