Running the Application
As DdlUtils is still in development and has no binary release as of the writing of this article, you can get the code from the repository
and do a build (Method 2), or you can use the jars from the extjars folder in the code download (Method 1).
The following are the instructions for the two methods:
- Install the code download in your favorite C drive or D drive.
- Rename cp.bat_txt to cp.bat.
- Edit cp.bat and change
- Open a command prompt window and run cp.bat.
$> javac MySimpleApp.java.
$> java MySimpleApp DBSchema.xml.
- Download Java DB from developers.sun.com.
- Download DdlUtils from http://db.apache.org.
- As there is no binary distribution available at this time for DdlUtils, you have to download all Jakarta Commons packages from jakarta.apache.org/commons:
- Include all the packages in the class path to compile MySimpleApp.java (from the code download) and run.
When the application starts, it instantiates the database. It then reads the database schema from the XML file and creates the schema. Data related to two users is inserted using DynaBeans. The application has a user interface for capturing the username and password from the user and validates it against the password stored in the embedded database (see Figure 1
|Figure 1. Initial Screen Using tiger/singh or vijay/woods to Login|
Upon successful login, the next screen provides a list of available famous golf courses on the left-hand side and a list of golf courses the user has played on the right-hand side (see Figure 2).
|Figure 2. Golf Courses Listed on the Right Are Pulled from Java DB|
The application reads the list of golf courses the user has played from the database while launching the screen in Figure 2. As the database is used in embedded mode, it will shut down when the application is terminated.
Think of the Possibilities
What can be accomplished with an embedded Java database is left to the imaginations of software architects and developers. I am sure that a few years from now we will see many Java DB-backed interactive applications with zero downtime. Currently, plans are in the works to use Java DB as a repository for office productivity documents in Microsoft Office and OpenOffice, and in many of the new breed of AJAX-driven offerings. More importantly, Java DB addresses many of the functionality problems for mobile applications such as data replication.