Skip to content

Debug and Database inspection in Eclipse

Lars Kristensen edited this page Sep 18, 2019 · 6 revisions

Debugging in Eclipse

Debugging allows you to run a program interactively and inspect its state during the execution.

To debug an application right click in the GlassFish5 server (in the Servers tab) and press Debug. If the application / server is already running you can either stop the server and then choose Debug, or use Restart in Debug

Database connection and inspection

When we run the Java EE tweet application, it is checked if the database is already created. Otherwise the information from the entity classes are used to create the database automatically.

During application development it is in many cases useful to be able to inspect the database schemas and also the content of the database from Eclipse.

To inspect the database you first need to setup a database connection

  1. Go to Window > Show View > Other... > Data Management > Data Source Explorer.

  2. In the new window, right click in Database Connections and select New.

  3. Select Derby, name it Dat250TweetSimple and press Next.

  4. Configure a Derby Client JDBC Driver by clicking on the + icon to add.

    There was an error with the image

  5. In the Jar List tab, navigate to the glassfish installation folder, and select the derbyclient.jar plugin inside the lib folder

C:\glassfish5\javadb\lib

Note: if the Driver file is already created, choose Edit JAR/Zip to configure the path where our derby plugin should be located. File should be derbyclient.jar

  1. Now you need to fill the properties set in the glassfish-resources.xml file inside our project in the general tab. The file is located in src/main/webbapp/WEB_INF/.

The figure below shows both the glassfish-resources.xml configuration and the last step to setup the database connection.

There was an error with the image

  1. Press the Test Connection button to verify that the properties were properly set, then Finish.

If we navigate through the new Database displayed, the tables for the simple Tweet application is located in Dat250TweetSimple/Dat250TweetSimple/Schemas/ADMIN/Tables.

Right click in the Dat250TweetSimple (Apache Derby...) anc choose Open SQL Scrapbook which will open a window to that can be sed to run SQL commands against the Derby database.

The figure below shows the editor and the database views

There was an error with the image

The figure illustrates three commands

  1. one to display the current values (they should be three that we added in the browser)

  2. one to add a row

  3. and one to show how the new element was added.

The figure below shows the commands and the outputs from the Eclipse SQL Results window.

There was an error with the image