Introduction
This tutorial assumes you have some familiarity with Web application development using Java and with interacting with relational databases using JDBC. Knowledge of DB2 or WebSphere Studio Application Developer (Application Developer) is helpful but is not required.
The code used in this tutorial uses Struts, an open source framework for Web application development. Knowledge of Struts is not required for this tutorial, but if you're curious about using Struts see the the tutorial Struttin' your stuff with WebSphere Studio.
The focus of this tutorial is developing Java Data Objects (JDO) that are persisted in DB2 using Application Developer and TJDO, an open source implementation of the JDO Specification. You are encouraged to read more on JDO, TJDO, DB2, and Application Developer as appropriate (see Resources for some suggested reading) after completing this tutorial.
The Go-ForIt application was developed by the Developer Relations Technical Consulting team using Extreme Programming. It is a Web site for the fictitious company Go-ForIt.com. Go-ForIt.com is a personal errand service. A customer registers at the site and posts errands they need done; for example, picking up laundry, walking the dog, standing in line at the license branch, and so on. Independent contractors, known as Personal Assistants (PAs) can also register at the site and bid on posted errands. Go-ForIt matches up the winning bid with the customer in need and collects a percentage of the fee paid for completion of the errand.
The most recent version of the Go-ForIt application was written using Struts, an open source Framework for Web application development, and utilized the Data Access Object pattern to allow us to experiment with different technologies for persisting application data with minimal impact on the application code. This tutorial is based on our experiences using JDO to persist application data.
The Java Data Objects API was developed under the Java Community Process as JSR 12. It defines a series on interfaces that application developers can use to persist the Java Objects that they use in their application.
JDO gives developers an object view of their persistent data, unlike JDBC where the developer is responsible for translating between the object representation of their data classes and the relational database tables used to persist them.
Implementation of the interfaces in the JDO API is the responsibility of JDO Providers. The runtime classes that these Providers make available to developers allow developers to persist their data classes without explicit knowledge of the structure of the underlying database tables used. JDO Providers also handle issues like caching and data concurrency, leaving you free to focus on the business logic of your applications. Several JDO Providers are available to choose from (see the JDOCentral link under Resources). In this tutorial I'll use TJDO, an open source JDO implementation that supports DB2 and several other relational databases.
TriActive JDO, or TJDO, is an open source implementation of the JDO Specification (Version 1.0). The highlights of this implementation, as described at the TJDO Web site, are that it:
- Implements the entire JDOQL query language, including several useful method enhancements.
- Auto-creates all necessary schema elements (tables, foreign keys, indexes) according to your app's classes and JDO metadata.
- Auto-validates expected schema structure at runtime, reducing failures from schema evolution.
- Can map Java classes to SQL views, and allows for direct SQL queries, to leverage SQL capabilities not normally accessible through JDO.
- Is designed to be lightweight and fast.
As of the time of this writing the available version is 2.0 Beta 3.
WebSphere Studio Application Developer
IBM WebSphere Studio Application Developer (Application Developer) is IBM's integrated development environment (IDE) for J2EE developers and Java programmers. It is based on WebSphere Studio Workbench, IBM's open tool integration platform. WebSphere Studio Workbench is built on the open-source Eclipse Platform. Eclipse.org is a consortium of development tool providers that are working to provide a common platform for seamless integration of tools from different vendors.
Application Developer's user interface is based on perspectives. A perspective is a group of related views and editors. Application Developer contains several perspectives geared towards role-based development. Different roles use different perspectives; for example, a Web developer might use the Web perspective, while an EJB developer might use the J2EE perspective.
DB2 Universal Database Express Edition V8.1
DB2 Universal Database Express Edition V8.1 (DB2 Express) is the newest member of the DB2 Universal Database product family. DB2 Express is a specially tailored full-featured relational database for small and medium business.
DB2 Express includes:
- JDBC, MDAC 2.7, ODBC, OLE BD, SQLJ support
- Satellite synchronization
- Spatial and XML Extender
- Support for the following communication protocols: APPC, NetBIOS, TCP/IP, Named Pipes
You can run DB2 Express on Windows NT/2000/2003/XP or on Linux.
The following software is required for this tutorial:
- WebSphere Studio Application Developer Version 5.0. You can download a trial version here.
- DB2 Universal Database Express Edition V8.1. You can download a trial version here.
- jdotutorial.zip: Download a small slice of the Go-ForIt application to use as a starting point for the tutorial. This contains a set of JSP pages and Struts components. I've also included the library files from the Struts 1.1 RC1 distribution, the TJDO Version 2.0 Beta 3 runtime files, the Apache Xerces XML parser and the Log4J runtime files (the latter two are both required by TJDO).


