Skip to Content

Hi,

I was asked by some developers, who executed SAP NW Cloud Application Development Scenario End-to-End Tutorial which “Database Viewer” one could use to displayed the stored data when testing the application locally.

I will answer this question by means of the below step-by-step description which might be helpful especially for NW Cloud beginners.

There it is explained how to use the Eclipse “Data Source Explorer” to display database (db) content which has been created by a Web Application running locally on NW Cloud test server

As example I use here the persons-list application which has been developed as part of the Scenario End-to-End Tutorial, but of course this kind of displaying db contents works for other locally running NetWeaver (NW) Cloud applications as well.

Prerequisite:

For the below description we make use of the following NW Cloud application

– Install the Ready-to-Run Sample Application

There in chapter 3.1 you run the “e2e-nwcloud-app-persons-list” application on the Local Test Server for NW Cloud.

From the running persons-list Web Application you create persons (firstname and lastname) which are stored in an embedded Derby db which is already part of the Eclipse installation.

Unfortunately you cannot connect to this embedded Derby db via a db viewer (like the “Data Source Explorer” Eclipse view) because the embedded derby db allows only one connection which is already established by the Web application, so that a db viewer is not able to establish a separate connection.

To solve this problem you could do the following four steps:

  • Install a standalone derby db (1.)
  • Start the derby db as server (2.)
  • Connect the Local Test Server for NW Cloud to the standalone derby db (3.)
  • Connect the “Data Source Explorer” Eclipse view to the standalone derby db (4.)

To do so just execute the following step-by-step description:

1. Install a standalone derby db

(e.g. I downloaded “db-derby-10.9.1.0-bin.zip” and extracted the content “db-derby-10.9.1.0-bin” to C:\)

  • Set the environment variable DERBY_HOME to the derby installation directory (e.g. C:\db-derby-10.9.1.0-bin)
  • Add %DERBY_HOME%/bin to the “path” system environment variable

This quick derby installation should be sufficient but if you want to get more installation and other details refer to http://db.apache.org/derby/

2. Start the derby db as server

  • Open command window and execute command “java -jar %DERBY_HOME%\lib\derbyrun.jar server start” to start the derby server

/wp-content/uploads/2012/12/db_1_162136.png

3. Connect the Local Test Server for NW Cloud to the standalone derby db

It is assumed here that you published and run the “e2e-nwcloud-app-persons-list” web application on the Local Test Server for NW Cloud.

(as described in chapter 3.1 of document http://scn.sap.com/docs/DOC-33514).

From there on do the following:

  • On Servers view select the “Test Server for SAP NetWeaver Cloud” server node and stop it (Right context menu > Stop).
  • On Project Explore view navigate to Servers > Local Test Server for SAP NetWeaver Cloud > config_master > connection_data > connection.properties

/wp-content/uploads/2012/12/db_2_162179.png

  • Open connection.properties file with Text Viewer
  • Replace the existing connection settings with the following:

       javax.persistence.jdbc.driver=org.apache.derby.jdbc.ClientDriver

       javax.persistence.jdbc.url=jdbc:derby://localhost:1527/DemoDB;create=true

       javax.persistence.jdbc.user=demo

       javax.persistence.jdbc.password=demo

       eclipselink.target-database=Derby

  • Save connection.properties
  • On Servers view select the “Test Server for SAP NetWeaver Cloud” server node and start it (Right context menu > Start).

With these steps the “Test Server for SAP NetWeaver Cloud” server on which the “e2e-nwcloud-app-persons-list” web application is already deployed is connected to the newly installed derby db

       (this name of the db has been specified in the connection.properties)

/wp-content/uploads/2012/12/db_3_162180.png

  • In the persons-list web application create a new entry “John Smith” which is stored then in the db DemoDB

/wp-content/uploads/2012/12/db_4_162181.png

4. Connect the “Data Source Explorer” Eclipse view to the standalone derby db

Follow the screenshot sequence to create a new Derby Connection Profile and display the database content that was created by the web application (John Smith)

Define New Database Connection in Data Source Explorer view

/wp-content/uploads/2012/12/db_5_162185.png

/wp-content/uploads/2012/12/db_6_162186.png

Add new Derby Embedded JDBC Driver of version 10.2

/wp-content/uploads/2012/12/db_7_162187.png

Specify derbyclient.jar location

/wp-content/uploads/2012/12/db_8_162188.png

The remove derbyclient.jar entry from JAR list

/wp-content/uploads/2012/12/db_9_162190.png

After that confirm New Driver Definition dialog with OK.

On the Derby Connection Profile specify the properties as shown in the following screenshot; especially the name of the db: DemoDB (as specified in connection.properties)

/wp-content/uploads/2012/12/db_9_1_162191.png

Then open T_PERSON data for edit

/wp-content/uploads/2012/12/db_9_2_162192.png

Confirm that the before created person data “John Smith” is displayed in the data editor.

/wp-content/uploads/2012/12/db_9_3_162193.png

Additional Info: MaxDB

You could also install a MaxDB (for installation see here http://scn.sap.com/docs/DOC-8406) and do corresponding changes (connection.properties) as described above and work then with MaxDB as standalone db.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Robin van het Hof

    Hi Jens,

    Thanks for sharing this information, it has saved me a *lot* of time and frustration! ๐Ÿ˜‰

    For all my fellow OS X developers, you need to set the Derby environment variable (I have set it in the .bashrc file in my home directory):

    DERBY_HOME=/path/to/derby/jarfiles

    export DERBY_HOME

    (0) 

Leave a Reply