-
Notifications
You must be signed in to change notification settings - Fork 3
Debug and Database inspection 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
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
-
Go to Window > Show View > Other... > Data Management > Data Source Explorer.
-
In the new window, right click in Database Connections and select New.
-
Select Derby, name it Dat250TweetSimple and press Next.
-
Configure a Derby Client JDBC Driver by clicking on the + icon to add.
-
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
- 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 insrc/main/webbapp/WEB_INF/
.
The figure below shows both the glassfish-resources.xml
configuration and the last step to setup the database connection.
- 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
The figure illustrates three commands
-
one to display the current values (they should be three that we added in the browser)
-
one to add a row
-
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.