Note You require Derby's client JDBC driver derbyclient.jar (located in the lib directory of the Derby
installation) to connect to the Derby server.
Table 3-1. JDBC Properties for Connecting to the Application Database
jdbc: derby://localhost:1527/vehicle; create=true
The first time you connect to this database, the database instance vehicle will be created, if it did
not exist before, because you specified create=true in the URL. Note that the specification of this
parameter will not cause the re-creation of the database if it already exists.
Follow these steps to connect to Derby:
1. Open a shell on your platform.
2. Type java -jar $DERBY_HOME/lib/derbyrun.jar ij on Unix variants or
%DERBY_HOME%/lib/derbyrun.jar ij on Windows.
3. Issue the command CONNECT 'jdbc: derby://localhost:1527/
You can provide any values for the username and password because Derby disables authentication
by default. Next, you have to create the VEHICLE table for storing vehicle records with the following SQL
statement. By default, this table will be created in the APP database schema.
CREATE TABLE VEHICLE (
VEHICLE_NO VARCHAR(10) NOT NULL,
PRIMARY KEY (VEHICLE_NO)
Understanding the Data Access Object Design Pattern
A typical design mistake made by inexperienced developers is to mix different types of logic (e.g.,
presentation logic, business logic, and data access logic) in a single large module. This reduces the
module's reusability and maintainability because of the tight coupling it introduces. The general
purpose of the Data Access Object (DAO) pattern is to avoid these problems by separating data access
logic from business logic and presentation logic. This pattern recommends that data access logic be
encapsulated in independent modules called data access objects.