Java Reference
In-Depth Information
with the JDBC API and a JPA engine with a JDBC driver. Hibernate can be configured as a JPA-compliant
engine through an extension module called Hibernate EntityManager . This chapter will mainly
demonstrate JPA with Hibernate as the underlying engine.
Problems with Direct JDBC
Suppose that you are going to develop an application for vehicle registration, whose major functions are
the basic CRUD (create, read, update, and delete) operations on vehicle records. These records will be
stored in a relational database and accessed with JDBC. First, you design the following Vehicle class,
which represents a vehicle in Java:
package com.apress.springenterpriserecipes.vehicle;
public class Vehicle {
private String vehicleNo;
private String color;
private int wheel;
private int seat;
// Constructors, Getters and Setters
...
}
Setting Up the Application Database
Before developing your vehicle registration application, you have to set up the database for it.
For the sake of low memory consumption and easy configuration, I have chosen Apache Derby
( http://db.apache.org/derby / ) as my database engine. Derby is an open source relational database
engine provided under the Apache License and implemented in pure Java.
Note You can download the Apache Derby binary distribution (e.g., v10.3) from the Apache Derby web site and
extract it to a directory of your choice to complete the installation.
Derby can run in either the embedded mode or the client/server mode. For testing purposes, the
client/server mode is more appropriate because it allows you to inspect and edit data with any visual
database tools that support JDBC—for example, the Eclipse Data Tools Platform (DTP).
Note To start the Derby server in the client/server mode, just execute the startNetworkServer script for your
platform (located in the bin directory of the Derby installation).
After starting up the Derby network server on localhost, you can connect to it with the JDBC
properties shown in Table 3-1.
 
Search WWH ::




Custom Search