Skip to Content
Author's profile photo Vijay Kumar Kalluri

SAP UI5 Application is connected to Non SAP System (SQL Database) Using EJB & REST Service

I’m writing this blog post to share my experience on a specific development task on SAP NetWeaver Portal 7.3.I developed SAPUI5 application is connected to Non SAP systems (SQL) by using EJB and REST web application.


SAP Enterprise Portal 7.3

Development Tool: NWDS 7.3 SP07

SAPUI5 Development Skills: HTML5, JavaScript, CSS3, AJAX/JSON and JQuery.

Connect Back-end Systems: EJB & REST Service (3rd Party Systems).

STEP 1:- I have installed SAPUI5 Plug-Ins in NWDS 7.3 SP07 using the block post

Developing SAP UI5 applications in SAP NetWeaver Developer Studio  – Part 1/2

Developing SAP UI5 applications in SAP NetWeaver Developer Studio  – Part 2/2

STEP 2:- I created “JDBC Custom Data Source” connection between Portal and SQL Database in NWA.

  1. Downloaded the required (ojdbc6.jar) jars from the google.
  2. In NWA, Configuration Management —> Infrastructure —>Application Resources Select Create New Resource -> Deploy new JDBC driver



   3. Again, Select Create new resource -> New JDBC Custom DataSource.


4. Created Custom data source alias in Dependent DataSource Aliases tab:


5.  Finally we have custom DataSource and a DataSource Aliases tab.

STEP 3:-

I created EJB application called “rest/ejb”, web application called “REST/Web” and ear application (for deploy ejb/web applications) under J2EE perspective.


I created Session Bean with

Note: – Mainly my application is follows CURD methods, in this blog I include only search the data from the SQL System using REST Service. Same way will follow any methods like Insert/Delete/Update etc…

           1. Connected SQL System by using below code in “Manager.JAVA”. PFB code for your Reference.


               2. Code for Search the data from SQL Data Base. PFB code for your Reference            

@WebMethod(operationName=”Manager”, exclude=false)

    public List<PtnerGroup> querySearchManager(

                @WebParam(name=”groupName”) String groupName,

                @WebParam(name=”countryName”) String countryName

       List<PtnerGroup> pgList = new LinkedList<PtnerGroup>();

        Connection connection = null;

        Statement st = null;

        ResultSet rs = null;


  connection = this.getConnection(null);

  String sql = “select * from TABLENAME_GROUPS where”;

  if (!”*”.equalsIgnoreCase(groupName) && groupName != null

  && groupName.trim().length() > 0) {

  sql = sql + ” (LOWER(name) like LOWER(‘%” + groupName

  + “%’) OR group_id like ‘%” + groupName + “%’) AND”;


  if (!”*”.equalsIgnoreCase(countryName) && countryName != null

  && countryName.trim().length() > 0) {

  sql = sql + ” (LOWER(country_name) like LOWER(‘%” + countryName

  + “%’) OR COUNTRY_ID LIKE ‘%” + countryName + “%’) “;


  if (sql.endsWith(“where”)) {

  sql = sql.replace(“where”, “”);


  if (sql.endsWith(“AND”)) {

  sql = sql.replace(“AND”, ” “);


  if (!sql.contains(“order by”)) {

  sql = sql + “order by GROUP_ID”;


  //System.err.println(“SQL Query:”+sql);

  st = connection.createStatement();

  rs = st.executeQuery(sql);

  while ( {

  PtnerGroup pg = new PtnerGroup(rs.getString(“GROUP_ID”), rs.getString(“NAME”),

  rs.getString(“COMMENTS”), rs.getString(“COUNTRY_ID”), rs.getString(“COUNTRY_NAME”),

  rs.getString(“BRAND_ID”), rs.getString(“BRAND_NAME”));



  return pgList;


        } catch (SQLException e) {

            logger.traceThrowableT(Severity.ERROR, null, e);

      } finally {

            try {

                  if (st != null)


                  if (connection != null)


            } catch (SQLException e) {

                  // TODO Auto-generated catch block




    return null;


       3. Now go the REST/Web application creates “ManagerGroupRest.Java”. PFB code for your Reference.



public class ManagerGroupRest {

  final String JNDI_NAME = “”;

  public ManagerGroupRest(){



  private static final Location _location = Location




  @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON,MediaType.TEXT_PLAIN })

  @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })

  public Response queryPrtGroup(ManagerGroupSearch search){

  _location.infoT(“in method queryPrtGroup”);

  String groupName = search.getGroupName();

  String countryName = search.getCountryName(); 

  //System.err.println(“Group Name:”+groupName);




  InitialContext jndiContext = new javax.naming.InitialContext();

  GroupManagerLocal inventoryMgr = (GroupManagerLocal) jndiContext.lookup(JNDI_NAME);

  List<PtnerGroup> list = inventoryMgr.querySearchGroupManager(groupName, countryName);


  if (list == null) {


  return Response.status(Status.INTERNAL_SERVER_ERROR).build();

  } else {

  GenericEntity<List<PtnerGroup>> entity = new GenericEntity<List<PtnerGroup>>(list) {};


  return Response.ok(entity).build();



  catch(NamingException e)




  return null;



By using REST application I will generate REST URL like(http://hostname:50000/

4.  Now test your rest URL is working or not in Mozilla Firefox. Install REST Plug-ins in Mozilla Firefox.


5. After test the REST application Firefox the data will display in “Response Body(Preview)” and if will have any error/issues will get the status in “Response Header

STEP 4:-

Created SAP UI5 Application or Create Web application (under “WebContent” we have to create all required (HTML5, JavaScript, CSS3, AJAX/JSON and JQuery) and deploy the application in Server) in NWDS


When we click on Submit Query. we will read the data from  INPUT FIELDS and send to the REST Service by using below code


Once we received the data from SQL System, same data we are going to bind to the table by using below code


Code for Model.Js file


Output of the SAPUI5 Application


STEP 5:- Same scenario we will develop the Update/Create/Delete etc… functionalities.

  Hope this is help full


Vijay Kalluri

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Jun Wu
      Jun Wu

      nice job Vijay

      Author's profile photo Santhosh Gowda
      Santhosh Gowda

      Good Work, Thanks for sharing.

      Author's profile photo Former Member
      Former Member

      Nice blog,thanks for sharing

      Author's profile photo Arun Padmanabhan
      Arun Padmanabhan

      Nice Blog bro..

      Author's profile photo Venkata Ramireddy
      Venkata Ramireddy

      Very use full blog for UI5 learners.

      Author's profile photo Former Member
      Former Member

      Very helpful..Thanks!!

      Author's profile photo Former Member
      Former Member

      Nice and usefull Blog

      Author's profile photo Former Member
      Former Member

      Hi Vijay,

      Its very nice blog and Good job 🙂