j kickstart pdf

69
Kick-start your Java apps, Part 1: Free software, fast development Skill Level: Intermediate Sing Li ([email protected]) Author Wrox Press 27 Feb 2006 Updated 05 Dec 2007 To create, test, and deploy a Web-based application or Web service rapidly, you need a proven relational database, a standards-compliant Web application server, and a flexible IDE. Ideally, all these software packages are production-tested, simple to obtain, easy to use, and well integrated with one another. This tutorial shows you how to use IBM-backed open source and free software to kick-start your Java™ Web-based application development. You'll learn exactly where to download such components, install them, and get them working for you today . Section 1. Before you start Combine the proven power of the industrial-strength DB2® database with the versatility of the Java EE 5 compatible WebSphere® Application Server, then throw in the popular open source Eclipse IDE — and you can have a highly productive environment to create, test, and deploy Web-based applications and Web services. This is not a secret, and professionals in large IT projects have been enjoying this proven collection of software for years. But until recently, the development community at large has not had general access to these tools. Times have changed, though, and today full-featured editions of the servers and IDE in this collection are only a download away — free of charge and free of license fees — with full support from IBM. Free software, fast development Trademarks  © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 1 of 69

Upload: piyush-chandra

Post on 09-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 1/69

Kick-start your Java apps, Part 1: Free software,fast developmentSkill Level: Intermediate

Sing Li ([email protected])AuthorWrox Press

27 Feb 2006

Updated 05 Dec 2007

To create, test, and deploy a Web-based application or Web service rapidly, youneed a proven relational database, a standards-compliant Web application server,and a flexible IDE. Ideally, all these software packages are production-tested, simpleto obtain, easy to use, and well integrated with one another. This tutorial shows youhow to use IBM-backed open source and free software to kick-start your Java™Web-based application development. You'll learn exactly where to download suchcomponents, install them, and get them working for you today.

Section 1. Before you start

Combine the proven power of the industrial-strength DB2® database with theversatility of the Java EE 5 compatible WebSphere® Application Server, then throwin the popular open source Eclipse IDE — and you can have a highly productiveenvironment to create, test, and deploy Web-based applications and Web services.

This is not a secret, and professionals in large IT projects have been enjoying thisproven collection of software for years. But until recently, the developmentcommunity at large has not had general access to these tools. Times have changed,though, and today full-featured editions of the servers and IDE in this collection areonly a download away — free of charge and free of license fees — with full supportfrom IBM.

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 1 of 69

Page 2: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 2/69

Java developers can now freely use the open source Eclipse IDE to create and testapplications and Web services and then install them to WebSphere ApplicationServer Community Edition 2.0 (referred to throughout this tutorial as ApplicationServer), and DB2 Express-C 9.5 for production deployment.

About this tutorial

The Kick-start comboWith the Kick-start your Java apps suite, IBM has put together apowerful combination of freely available software components fordata, deployment, and development:

• DB2 Express-C 9.5 database server

• WebSphere Application Server Community Edition 2.0

• The Eclipse IDE

You're not locked in to using these packages in combination; eachworks with a variety of other open-standards based components.You can use Eclipse with other (even non-Java) application serversand other databases. Application Server doesn't require either DB2Express-C 9.5 or Eclipse. And DB2 Express-C 9.5 can fit intodevelopment and deployment environments other than Eclipse andApplication Server. But, in ways you'll understand fully from thistutorial, using the whole, tightly integrated suite can gain you awealth of advantages.

This tutorial takes you along the shortest path to getting these software components

 — called the Kick-start your Java apps suite — downloaded and working, letting youdiscover their infinite possibilities while creating your next programming masterpiece.It assists you in installing and setting up the components and reveals how they aredesigned to work with one another. Toward this goal, the tutorial does not attempt tocover all possible features or configuration options available for the individualpackages. You'll be able to discover each product's rich feature set at your own paceas you continue exploration and development.

This tutorial guides you through:

• Downloading and installing DB2 Express-C 9.5

• Creating databases and manipulating data with tools in DB2 Express-C9.5

• Downloading and installing Application Server 2.0

• Managing Application Server through the Web console

• Connecting Application Server to DB2 Express-C 9.5 using a JCA 1.5

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 2 of 69

Page 3: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 3/69

connector

• Downloading and installing Eclipse

• Installing the Eclipse Web Tools Platform (WTP) server adapter forApplication Server (formerly called the Application Server plug-in for

Eclipse)

• Managing, browsing, and editing DB2 Express-C 9.5 data through theEclipse IDE

• Testing Web applications in Eclipse using existing Application Serverinstallation

• Rapidly developing and testing a JSP/JSTL Web application in Eclipse,with data access to DB2 Express-C 9.5, and deploying it to ApplicationServer

• Configuring Application Server as a general Web server on the Internet

By the end of the tutorial, you'll have hands-on working experience with all thesoftware tools and have a simple data-driven Java application deployed onApplication Server.

Prerequisites

You should be familiar with Java development in general and server-side Javadevelopment specifically. This tutorial assumes that you understand the generaloperations of a relational database and are familiar with basic Java EE concepts,

such as deployment descriptors and WAR archives. Experience working with anapplication server and relational database is beneficial but not mandatory.

System requirements

To follow along and try out the code for this tutorial, you need a working installationof Sun's Java SE JDK 5 update 15 or the IBM SDK for Java Version 5 SR6.

The recommended system configuration for trying out the tutorial is:

• A system supporting the JDK/JRE listed above with at least 1GB of mainmemory (2GB recommended)

• At least 2GB of disk space to install the software components andexamples

The instructions in the tutorial are based on a Windows™ operating system. All ofthe tools covered in the tutorial also work on Linux® and UNIX® systems.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 3 of 69

Page 4: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 4/69

Section 2. Overview

The Kick-start your Java apps suite of software includes the following products andversions, which are designed to work well together:

• A database server: DB2 Express-C (currently at UDB 9.5 level)

• An application server: WebSphere Application Server CommunityEdition (currently release 2.0.0.1)

• An IDE: Eclipse (currently version 3.3 for use with the WTP serveradapter V2.0 for Application Server)

You can download and use all of these packages for free.

Figure 1 illustrates how these products fit together for server-side Java applicationdevelopment:

Figure 1. Eclipse, Application Server, and DB2 Express-C 9.5 working together

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 4 of 69

Page 5: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 5/69

Code, test, and debug in the Eclipse IDE

As Figure 1 illustrates, you can write, test, and debug your Java applications usingthe Eclipse IDE. DB2 Express-C 9.5 integrates with the Eclipse IDE to provide you

with easy access to your database content as well as metadata information, such asschema, table, and field names. You can control instances of Application Serverfrom the Eclipse IDE to deploy and test your application components rapidly.

In addition to working with them together as a concept-to-production toolkit, you canuse each of these products alone or with a myriad of available interfacingtechnology. For example, you can access DB2 Express-C 9.5 through C/C++,Python, Ruby, and Perl APIs, among others.

Deploy applications on Application Server and DB2 Express-C

9.5Once you have tested your application in Eclipse, you can deploy it into productionrunning inside Application Server. Application Server is a Java EE 5 compatibleapplication server that can host applications constructed from Web componentssuch as JavaServer Pages (JSP), servlets, and Enterprise JavaBeans (EJB). Youcan use Eclipse and Application Server with modern, open source, lightweightframeworks such as the Spring Framework and Hibernate. Application Server alsodoubles as a general-purpose Web server for static HTML pages and graphics files.Users can access your application through a browser pointed to Application Server.

Your production applications, hosted on Application Server, can use DB2 Express-C9.5 to store any application data. DB2 Express-C 9.5 supports Java-based dataaccess through JDBC. It includes a fully licensed, high-performance type 4, 100%Java JDBC driver. This driver works very well with 100% Java applications requiringrelational database management system (RDBMS) access.

Application Server has built-in support for Java EE Connector Architecture (JCA) 1.5resource adapters and can make use of the DB2 Express-C 9.5 JDBC driver toprovide data persistence for any hosted application.

Section 3. Introducing DB2 Express-C 9.5

As a member of the DB2 Universal Database™ family, DB2 Express-C 9.5 is thefree edition of the modern version of a "very big iron" RDBMS. This section

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 5 of 69

Page 6: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 6/69

introduces DB2 Express-C 9.5, and the following three sections show you how todownload, install, and operate it. If you are already committed to a different databasethat you'd like to use with Eclipse and/or Application Server in this tutorial, feel freeto skip these sections.

The robust, proven, and scalable database server

The core technology of DB2 has existed as an IBM product since 1983 and is amature and robust database engine. International enterprises use DB2 today tomaintain some of the largest databases on servers that run around the clock. TheDB2 server is designed from the ground up to handle virtually unlimited scalability. Itcan handle increasing demand by scaling up (by adding more CPU and memory toone server) or scaling out (by adding more servers over an interconnection network).On a development system where the test databases are small, you can havemultiple instances running on one machine; when building very large database

systems, you can have a cluster of multiple machines working together to run asingle logical database instance.

Built-in management and business application features

DB2 Express-C 9.5 is optimized for running on widely available 32-bit and 64-bitmicroprocessor-based server hardware and has built-in self-monitoring,maintenance, and tuning features that take most of the tedious work out ofmaintaining a database server. It is especially cost-effective for small enterpriseinstallations because it eliminates the need to retain full-time database

administration staff.

Transactions, XA distributed transactions, stored procedures, referential constraints,and triggers have been well-tested, built-in features of DB2 servers for over adecade.

Integration with XML data

DB2 Express-C 9.5 has built-in capabilities for handling and working with XML data.XML documents are stored hierarchically in a table's columns. DB2 Express-C 9.5

integrates native XML storage and XQuery capabilities. The hybrid relational andXML nature of DB2 Express-C 9.5 lets developers satisfy the XML data storageneeds of modern Web services and systems based on service-oriented architecture(SOA).

DB2 Express-C 9.5 can grow with your needs

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 6 of 69

Page 7: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 7/69

All the data content and schemas that you create using DB2 Express-C 9.5 aredirectly compatible — without the need to perform any conversions — with even thelargest member of the DB2 Universal Database family. Should your data needs growin the future, DB2 can grow with your needs.

There is practically no limit to the size of the databases that you can create andmanage with DB2 Express-C 9.5. Depending on your application and databasedesign, a server equipped with 2GB of main memory can readily handle databasesseveral gigabytes in size.

A restriction with the free edition of DB2 Express-C 9.5 is the resource utilization,across all database instances, of two CPU cores and 2GB of memory. An alternativeannual-subscription version is available with a four CPU cores and 4GB limit.

If your needs grow past this range of capacity, the DB2 Universal Database family ofproducts provides a smooth, scalable growth path without the need to tackle costlyand often risky data conversion.

Section 4. Downloading and installing DB2 Express-C9.5

In this section, you'll download and install DB2 Express-C 9.5 and build a sampledatabase. The instructions in this tutorial cover the installation of DB2 Express-C 9.5

on 32-bit Windows-based systems only.

Downloading DB2 Express-C 9.5

To download DB2 Express-C 9.5, go to Download: IBM DB2 Express-C 9.5.

If you do not yet have an IBM ID, you need to register before downloading DB2 Express-C 9.5. Registration is free and takes just minutes.

The file you download, named db2exc_950_WIN_x86.zip, is in a compressed ZIP

format.

Before you proceed any further, you need to be aware that DB2 Express-C 9.5 usesthe operating system's authentication system to authenticate users. In the case ofWindows, it uses the name of the logged-in Windows user. Any tables that you buildin the database are created under a schema with that username. For this tutorial,make sure you are logged on to Windows as the same user who will create the

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 7 of 69

Page 8: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 8/69

application. This eliminates the need to assign a specific level of privileges for yourexplorations.

Installing DB2 Express-C 9.5

Unzip the downloaded file, db2exc_950_WIN_x86.zip, to a directory. Then runSETUP.EXE to begin installing DB2 Express-C 9.5. The DB2 Express-C 9.5 setupLaunchpad screen, shown in Figure 2, is displayed:

Figure 2. Setup Launchpad screen for DB2 Express-C 9.5 installer

The tabs on the left side link to various IBM informational Web sites. (Make sure you

are connected to the Internet.) Read the installation prerequisites, verify that yourhardware and software satisfy them, and read the release notes. Then click InstallProduct.

Follow the wizard's directions to install DB2 Express-C 9.5.

When prompted, select the Typical installation type, shown in Figure 3. This optiontakes up to 800MB of disk space.

Figure 3. Selecting typical installation for DB2 Express-C 9.5

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 8 of 69

Page 9: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 9/69

The next screen prompts you to save a response file. This file captures all theoptions you have selected and is handy if you need to install multiple database

instances or reinstall. The next screen asks for an installation folder. The default isthe Program Files\IBM\SQLLIB\ directory on the system drive. This tutorial refers tothis directory as the SQLLIB directory.

Installing the DB2 system services

The next wizard screen sets up the user authorized for the DB2 AdministrationServer (DAS). To keep things simple for this development system, select Use thesame user name and password for the remaining DB2 services, as shown inFigure 4:

Figure 4. Windows user authentication assignments for DB2 installation

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 9 of 69

Page 10: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 10/69

If you use db2admin as the user name, make sure you have created a user with thatname using control panel administration utilities. In the future, when you install

production server instance(s), you should consult the DB2 Administration ServerUser Guide to determine the security scenario most applicable to your installation.

Completing the installation

Follow the remaining steps in the installation wizard, accepting the defaults. Thisconfigures an instance called DB2 on your system and sets its default connectionprotocol to TCP/IP.

After the wizard completes the installation, you'll notice:

• A new green DB2 tray icon (lower right-hand side of the screen next tothe system clock).

• A new menu named IBM DB2 with a variety of administrative and usertools (under the Windows Start menu).

• The DB2 First Steps window appearing on your desktop, as shown in

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 10 of 69

Page 11: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 11/69

Figure 5:

Figure 5. DB2 First Steps window

Creating the sample database

The application example that you'll work on later in this tutorial (see Creating a Webapplication with Eclipse and WTP) makes use of a sample database. The defaultDB2 Express-C 9.5 installation creates the sample database as the last step in theinstallation, and you do not need create it explicitly. However, if you ever need tocreate or re-create this database manually, you can do so by following these steps:

1. Click the Database Creation link on the left-hand side of the First Stepswindow.

2. Click the Create the SAMPLE Database button.

3. On the next screen, select the default SQL objects and data only option.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 11 of 69

Page 12: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 12/69

4. The wizard proceeds to create a database called SAMPLE.

Section 5. Understanding the DB2 Express-C 9.5components

This section covers the DB2 Express-C 9.5 components you installed in thepreceding section (Downloading and installing DB2 Express-C 9.5). Thecomponents can be grouped into two categories:

• DB2 system services

• DB2 tools and utilities for administrators, users, and developers

DB2 system services

DB2 Express-C 9.5 is a database server that can process many data-access andadministration requests simultaneously. These requests can originate from the localmachine and any number of client machines accessing the server. Requests arereceived through the network and processed on the server machine(s) by a set ofcollaborating system services.

Table 1 describes the system services that are installed on your system:

Table 1. DB2 Express system services on Windows installations

Service name Executable name Description

DB2 System Controller db2syscs The main controller thatprovides access topersistent data andmanages storageallocation,memory-buffer pools,and so on. On Windowssystems, this controller

spawns threads toperform work; on Linuxsystems, it can spawnadditional processes toperform its work.

DB2 Governor db2govds Statistics collector forDB2 applications.

DB2 JDBC Applet db2jds Support for JDBC.

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 12 of 69

Page 13: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 13/69

Server

DB2 License Server db2licd Monitors and enforcesDB2 software licensepolicies.

DB2 Security Server db2sec Authentication server

for clients.

DB2 Remote CommandExecutor

db2rcmd Handles remotecommands for the DB2instance.

DB2 DatabaseAdministration Server

db2dasrrm Provides administrationservice functionality.

DB2 ManagementService

db2mgmtsvc Manages registry forbackward compatibilitywith earlier versions.

DB2 Fence ModeProcess

db2fmp Executes fenced storedprocedures and

user-defined functionsoutside the engine'saddress space (forsecurityimplementations).

DB2 system traymanager

db2systray Not strictly a service,this provides a tray iconon the Windowsdesktop for quickaccess to DB2 utilities.

If you examine the Windows Task Manager's task list (type Ctrl-Alt-Delete to invokethe Task Manager), you'll see several of these services running.

DB2 tools for administrators, users, and developers

Other than system services, the typical DB2 installation includes a rich set of tools.Figure 6 provides an overview:

Figure 6. Tools and developer support for DB2 Express-C 9.5

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 13 of 69

Page 14: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 14/69

In Figure 6, the tools for DB2 Express-C 9.5 can be generally classified ascommand-line based or GUI-based .

Development support

Java development support in DB2 Express-C 9.5 includes access through JDBC (atype 4 driver and a type 2 driver are available) and SQLJ static embedded SQL.Windows .NET developers can use the add-in support for development using theMicrosoft Visual Studio .NET development environment. Open source developerscan take advantage of the support for development using popular scriptingenvironments, including Perl, PHP, Python, and Ruby.

GUI-based tools

Table 2 briefly describes some of the GUI tools provided with DB2 Express-C 9.5.You can explore these tools at your leisure:

Table 2. GUI tools included with DB2 Express-C 9.5 installation

Tool Access to tool Description

DB2 Control Center• IBM DB2 >

General

Examines instances, databases,schemas, tables, etc. Can view,add, or modify objects and

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 14 of 69

Page 15: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 15/69

AdministrationTools > ControlCenter

• Right-click the trayicon and select

DB2 Control Center• db2cc from

command line

perform most administrationtasks. Also launches otherGUI-based tools.

DB2 Information Center• IBM DB2 >

Information >InformationCenter

• db2ic fromcommand line

Launches browser to a Web sitecontaining comprehensiveup-to-date documentation andinformation on the DB2 server.

DB2 Development Center• IBM DB2 >

Development >DevelopmentCenter

• db2dc fromcommand line

IDE tool that creates, builds,and deploys stored proceduresand user-defined functions.

DB2 Replication Center• IBM DB2 >

GeneralAdministrationTools >ReplicationCenter

• db2rc fromcommand line

Sets up replication environmentfor DB2-to-DB2 replication.Replication enables you tomaintain up-to-date copies of

your important data.

DB2 Task Center• IBM DB2 >

GeneralAdministrationTools > TaskCenter

•db2tc

fromcommand line

Tool that schedules scripts (DB2or OS) and notifies users of atask outcome.

See the DB2 documentation for information on other GUI tools.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 15 of 69

Page 16: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 16/69

Section 6. Working with the DB2 Command LineProcessor

Some system administrators prefer a command-line interface over a GUI tool for thepurpose of server control. Many tedious custom administrative tasks can beautomated by creating scripts that execute against a command-line interface. Thissection explores the command-line interface for DB2 Express-C 9.5.

The DB2 Express-C 9.5 Command Line Processor

If you are more comfortable with a command-line interface to relational databaseservers than with a GUI tool, you'll feel right at home with DB2 Express-C 9.5's

Command Line Processor (CLP). The DB2 CLP lets you work with the DB2database using an interactive command-line interface with a rich set of commands.You can literally perform everything that you can do from the GUI tools by using theCLP.

To start the CLP, select IBM DB2 > DB2COPY1(Default) > Command Line Tools> Command Line Processor from the Windows Start menu. Alternatively,assuming you have set up your environment PATH variable to include SQLLIB\BIN,you can use the following command:

db2

Figure 7 shows the DB2 CLP's greeting screen:

Figure 7. Logging on to the CLP of DB2 Express-C 9.5

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 16 of 69

Page 17: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 17/69

Data query with DB2 CLP

The interactive CLP takes SQL commands as well as DB2-specific controlcommands. To connect to the SAMPLE database, enter the following command:

connect to sample

Figure 8 shows the result of this command. You are now connected to the SAMPLEdatabase:

Figure 8. Connecting to the SAMPLE database through the DB2 Express-C 9.5CLP

The SAMPLE database contains a table of employee information called EMPLOYEE.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 17 of 69

Page 18: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 18/69

You'll use this table throughout the remainder of this tutorial.

You can directly enter SQL queries against the table. Try the following:

select * from employee where empno='000300'

The result is shown in Figure 9:

Figure 9. Command-line SQL queries in an interactive CLP session

In Figure 9, the result is the record for Philip Smith, who has the employee numberof 000300.

In addition to the standard SQL commands, many DB2-specific commands areavailable. You can use the ? command at any time to get help.

To see the structure of the EMPLOYEE table, enter the following:

describe table employee

This command shows the fields structure of the EMPLOYEE table, as shown in Figure10:

Figure 10. Using the DESCRIBE command to display table schema

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 18 of 69

Page 19: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 19/69

Creating your own data tables through the DB2 CLP

The DB2 CLP can take a text-based script file as input and execute each line of thescript as if it were entered at the command line.

The products.sql script file, found in the sql subdirectory of the code download forthis article (see Download), is shown in Listing 1:

Listing 1. The products.sql DB2 CLP script file for creating a table

CONNECT TO SAMPLE;

DROP TABLE PRODUCTS;

CREATE TABLE PRODUCTS (SKU CHAR(15) NOT NULL,DESCRIPTION VARCHAR(80) NOT NULL,PRICE DECIMAL(10,2),PRIMARY KEY(SKU)

);

INSERT INTO PRODUCTS VALUES('TV1020','70 inch Plasma TV',1299.00);

INSERT INTO PRODUCTS VALUES('CPU3818','PowerPC CPU',200.00);

INSERT INTO PRODUCTS VALUES('HDR2929','2 TB Hard Disk',899.00);

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 19 of 69

Page 20: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 20/69

This standard SQL script file connects to the SAMPLE database, creates a tablecalled PRODUCTS, and places three rows in the table.

The DB2 CLP can process this script. Just enter the following command:

db2 -vf products.sql -t

Figure 11 shows the result of this command:

Figure 11. Processing a DB2 command script file using the CLP

You can get more information on the options available with the CLP from theInformation Center. You can also explore the newly created database visually with

the Control Center.

The next section examines another important engine for your Web applications:WebSphere Application Server Community Edition.

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 20 of 69

Page 21: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 21/69

Section 7. Introducing WebSphere Application ServerCommunity Edition Version 2.0

WebSphere Application Server Community Edition (Application Server) is a Java EE5 compatible application server and a member of the IBM WebSphere family ofproducts. This section introduces you to Application Server's structure andfunctionality. If you prefer to use a different application server for the purposes of thistutorial, feel free to skip to Introducing the open source Eclipse IDE.

Server for Java EE 5 applications and Web services

Application Server is a free server that supports the production hosting of Web

applications and Web services created to the Java EE 5 standard. This includesapplications that can contain the following elements:

• JSPs

• Servlets

• JavaServer Faces (JSF) components

• Custom Java coding

• EJBs

• POJOs (plain old Java objects) with Java Persistence API (JPA)persistence support

• Model-view-controller (MVC) frameworks

• Lightweight development frameworks

• JCA 1.5 resource adapters connecting to EIS or legacy systems

• Other data-access components

Once a GeronimoThe Application Server code is based on the popular Apache Geronimo Serverproject (see Resources). As such, it comes with the capability to integrate with alarge body of open source technology. Moving forward, Application Server willcontinue to support tight integration with best-of-breed open source technology, suchas the Apache Tomcat Web container and the ActiveMQ message broker.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 21 of 69

Page 22: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 22/69

The AJP protocolThe AJP protocol is designed to enable the forwarding of requestsfor dynamic server contents (JSP and servlet) from an Apache Webserver to an instance of a container for Java Servlets or JSPs. Thefirst version of such a container was named JServ. Since then,however, Tomcat has taken over as the de facto open source

standard in Web-tier containers.

Application Server has built-in support to interoperate with legacy CORBA systemsthrough the open source Yoko project (see Resources). You can also use it todeploy and host Web services through its integration with Apache Axis (seeResources). And you can use Application Server as a general-purpose Web serverto support the serving of static HTML pages and graphical images.

For high-performance service of static Web assets, you can configure the ApacheJServ Protocol version 1.3 (AJP13) protocol connector to enable Application Serverto accept requests from an industry-standard Apache Web server (front end) (seeThe AJP protocol).

Application Server's open source pedigree

Figure 12 shows the composition of Application Server. You'll recognize many opensource server components:

Figure 12. Application Server's open source server components

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 22 of 69

Page 23: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 23/69

Table 3 summarizes the open source server components shown in Figure 12:

Table 3. The open source server components inside Application ServerServer Description

Apache Tomcat Popular container for Web-tier components.Tomcat implementations always track the latestJSP and Servlets specifications. Overwhelmingsupport from the developer and usercommunities has made it the de facto standard inopen source Web-tier containers. Four versionfamilies of Tomcat are available: 3.x, 4.x, 5.x,and 6.x. Application Server integrates with thelatest Tomcat 6 version. (See Resources forTomcat's open source community Web site.)

ActiveMQ Popular message broker that supports a rich setof transports. Supports the Java MessageService (JMS) 1.1 API. Includes a JCA 1.5resource adapter and support for MessageDriven Beans. (See Resources for ActiveMQ'sopen source community Web site.)

OpenEJB An EJB container supporting the EJB 3specification, including support for POJOs as

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 23 of 69

Page 24: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 24/69

EJBs, Container Managed Persistence over JPA,dependency injection, and annotations. (SeeResources for OpenEJB's open sourcecommunity Web site.)

Apache Derby Based originally on code from IBM's Cloudscapeproduct, Apache Derby is a full-featured RDBMScreated completely in Java code. ApplicationServer currently uses Apache Derby as its owninternal embedded database. (See Resources forApache Derby's open source community Website.)

Section 8. Downloading and installing Application Server

This section walks you through downloading Application Server (and, optionally,some additional items that might enhance your configuration) and performing theinstallation.

Downloading Application Server

To download Application Server 2.0.0.1, go to Download: WebSphere ApplicationServer Community Edition V2.0.

Important note: The instructions in this tutorial pertain to version2.0.0.1 of Application Server. This version is different from version2.0.0.0. Be sure to use version 2.0.0.1 or later as you follow alongwith this tutorial.

The Application Server distribution you download is in Windows EXE format.

The corresponding Eclipse WTP server adapter for Application Server (formerlycalled the Application Server plug-in for Eclipse) can be downloaded and installedusing the Eclipse update manager. You'll perform those steps later in this tutorial(see Downloading and installing Eclipse).

Optional additional downloads

In addition to the Application Server and WTP server adapter downloads, you mightalso want to download these items from the same site:

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 24 of 69

Page 25: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 25/69

• Application Server bundled with IBM Java 2 Version 5 SDK SR6

• Application Server sample applications

These downloads are not mandatory, but they can be helpful for your configuration.

Installing Application Server

To install Application Server, run the downloaded EXE file on your system. Theinstallation wizard prompts you for a directory for the installation. You can specifyyour own directory or accept the default.

To start the server after installation, select IBM WebSphere > Application ServerCommunity Edition > Start the server from the Windows Start menu.

You should see a command console open that displays the server startup

information, similar to Figure 13:

Figure 13. A system console showing output from the Application Serverstartup

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 25 of 69

Page 26: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 26/69

To verify the success of the installation, start the Administrative Console by opening

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 26 of 69

Page 27: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 27/69

a browser and pointing it to the URL http://localhost:8080/console.

This should bring you to the login page for the Administrative Console. TheAdministrative Console is actually a Web application running inside ApplicationServer. Figure 14 shows the login screen for the console:

Figure 14. The login screen for the Application Server Administrative Console

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 27 of 69

Page 28: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 28/69

If you wish to explore the Administrative Console, use the predefined username(system ) and password (manager ).

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 28 of 69

Page 29: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 29/69

Section 9. Operating your Application Server

As with DB2 Express-C 9.5, you can control the basic operations of your ApplicationServer through either the Administrative Console GUI or a command-line interface.This section describes the basic commands available through either user interface.

Starting the server

To start the server, select IBM WebSphere > Application Server CommunityEdition > Start the server from the Windows Start menu.

You can also change to the bin directory just below the Application Serverinstallation directory (or add the bin directory to your PATH environment variable)and issue this command:

startup

Stopping the server

To stop the server, choose one of these three methods:

• Log in to the Administrative Console and select Shutdown from its menuon the left-hand side.

• From the Windows Start menu, select IBM WebSphere > ApplicationServer Community Edition > Stop the server.

• Change directory to the bin directory just below Application Serverinstallation directory (or add the bin directory to your PATH environmentvariable) and issue this command:

shutdown

Application Server prompts you for a username and password (usesystem and manager ).

Obtain a list of installed applications

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 29 of 69

Page 30: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 30/69

On Application Server, installing applications to the server is called deployment .Applications that are deployed to Application Server are maintained by the server asmodules . To view the modules deployed on the server, log on to the AdministrativeConsole (using system for username and manager for password) and selectApplication EARs, Web App WARs, EJB JARs, or Application Clients.

You can also issue this command from a command line while you're in the binsubdirectory:

deploy list-modules

Application Server prompts you for a username and password (use system andmanager ). This runs the command-line deployer tool and obtains information on allthe modules deployed on this server. Figure 15 shows the output from alist-modules command:

Figure 15. Showing all modules deployed in a Application Server

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 30 of 69

Page 31: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 31/69

In Figure 15, a module name preceded by a plus sign (+) indicates that it is deployedand running. A module name without the + indicates that it is deployed but notcurrently running.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 31 of 69

Page 32: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 32/69

Section 10. Connecting Application Server to DB2

Express-C 9.5

In this section, you'll connect Application Server to DB2 Express-C 9.5. This lets anyapplication that's hosted in Application Server access the SAMPLE databasecontaining the EMPLOYEE and PRODUCTS tables that you created earlier in thetutorial (see Working with the DB2 Command Line Processor).

Deploying a resource adapter

To connect the Application Server with DB2 Express-C 9.5, you need to create anddeploy an instance of a JCA 1.5 resource adapter on Application Server thataccesses your DB2 SAMPLE database. This resource adapter instance uses theDB2 Express-C 9.5 type 4 JDBC driver to access the SAMPLE database. The actionthat you need to perform boils down to the following:

1. Adding the JDBC driver JAR files from the DB2 Express-C 9.5 installationto the Application Server repository.

2. Creating a database pool using the resource adapter configured with theJDBC driver.

3. Creating a deployment plan to deploy the resource adapter.

Add the JDBC driver JAR files from the DB2 Express-C 9.5installation to the Application Server repository

A JCA 1.5 resource adapter already exists in Application Server that works with theJDBC driver. However, the DB2 driver distributed as a standard part of ApplicationServer version 2.0.0.1 is version 9.1, so you need to add the 9.5 JDBC driversmanually to the Application Server repository. (Later versions of Application Serverwill likely include the 9.5 JDBC driver and you may not need to do this.)

The latest version of DB2 Express-C 9.5 comes with the 9.5 JDBC drivers set. You'llfind the following JDBC JARs in the SQLLIB\java directory:

• db2jcc.jar - The library JAR file

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 32 of 69

Page 33: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 33/69

Page 34: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 34/69

1. Enter the path to db2jcc.jar as File (use the Browse button to locate theJAR file), com.ibm.db2 as Group, db2jcc as Artifact, 9.5 as Version,and jar as Type.

2. Click Install.

3. Enter the path to db2jcc_license_cu.jar as File (use the Browse buttonto locate the JAR file), com.ibm.db2 as Group, db2jcc_license_cu asArtifact, 9.5 as Version, jar as Type.

4. Click Install.

Now that you have the JDBC driver files in place, you can use them to create adatabase pool.

Adding a system-wide database pool

The JCA resource adapter provides database pooling for all ApplicationServer-hosted applications. To deploy the adapter, log on to the AdministrativeConsole and click Database Pools in the menu on the left-hand side. You shouldsee the currently deployed database pools, as shown in Figure 17:

Figure 17. Displaying the currently configured database pools in ApplicationServer

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 34 of 69

Page 35: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 35/69

In Figure 17, the server-wide database pool called SystemDatasource accesses a

Derby database that is used internally by Application Server.

Click the Create a new database pool: Using the Geronimo database poolwizard option.

Fill in the details of the pool with the values shown in Table 4. This will involve thenext few screens of the wizard.

Table 4. Configuration for the Application Server database pool connecting toSAMPLE DB2 database

Field Value

Name of Database Pool dwDatasource

Database Type DB2

JDBC Driver Class com.ibm.db2.jcc.DB2Driver

Driver JAR CTRL-click or SHIFT-click to select both:com.ibm.db2/db2jcc/9.5/jarcom.ibm.db2/db2jcc_license_cu/9.5/jar

DB User Name Windows user name under which DB2 Express-C 

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 35 of 69

Page 36: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 36/69

9.5 is installed 

DB Password Windows user's password for DB2 Express-C 9.5 

Port 50000

Database sample

Host localhost

Leave the rest of the configuration empty, accepting the default values, and thenclick the Test Connection button. This causes Application Server to attempt toconnect to the SAMPLE database. If the attempt is successful, you should see ascreen similar to Figure 18:

Figure 18. Successful test connect to the DB2 Express-C 9.5 database fromApplication Server

Viewing and deploying the plan

The connection to DB2 Express-C 9.5 is now tested, but to access the data

successfully from Application Server, you must create and deploy a deploymentplan. This deployment plan can be generated for you automatically, by the wizard,based on your input. Follow these steps to view and then deploy the plan:

1. Click the Show Plan button (see Figure 18). This will display thegenerated deployment plan, shown in Listing 2.

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 36 of 69

Page 37: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 37/69

Page 38: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 38/69

Section 11. Introducing the open source Eclipse IDE

The open source Eclipse IDE is one of the most popular IDEs for Java developmentin the world. Eclipse is supported by a huge global community of users, developers,and researchers. (See Resources for a link to the Eclipse community Web site.) Thissection gives you an introduction to Eclipse.

Eclipse features useful for Java development

Eclipse is used daily by Java development teams across the world to code, debug,and test code bases that consist of up to millions of lines. Eclipse features that areattractive to developers in general and Java developers in particular include:

• Built-in smart editors for Java code, HTML, XML, and so on

• Full syntax highlighting on all editors

• Full syntax check as you enter your code

• Context-sensitive code assists for supported programming languages,including dynamic API documentation lookup

• Support for the development of standard Java applications, as well asJava EE targets, such as Web applications and Web services

• Support for design of POJO-based applications with JPA integration

• Tight integration with popular version-control systems, such asSubversion and CVS

• Tight integration with popular Java build tools, such as Apache Ant andApache Maven

• Tight integration with popular Java unit-testing frameworks, such as JUnit

• Ability to control, manage, and deploy applications to servers during thetest-and-debug cycle

• Tight integration with relational and nonrelational data sources throughJDBC and Open Data Access (ODA)

• One-click ability to find the declaration of a type or base type anywhere inthe source code

• One-click ability to look up all references to a type or symbol anywhere in

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 38 of 69

Page 39: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 39/69

the source code

• Refactoring tools that assist in the often tedious, complex, anderror-prone refactoring process

This is just a partial list of the features of Eclipse. You'll likely discover even more

useful features as you start coding with this workhorse IDE.

Reusable GUI framework

Eclipse's modular architecture encourages customization and code reuse. TheEclipse IDE's GUI is designed to be reusable, and many open source andcommercial products have leveraged Eclipse's open source code base. The DB2Express-C 9.5 Development Center is an example of a commercial productleveraging the Eclipse framework.

Plug-ins extend Eclipse beyond Java programming

In addition to the GUI framework, Eclipse has a well-specified plug-in API and richsupport for plug-in construction. This has created a foundation for an abundance ofhigh-quality, third-party plug-ins that extend well beyond the realm of Javadevelopment. Eclipse plug-ins provide support for other popular developmentlanguages, such as C/C++, Python, and Ruby on Rails.

Figure 19 illustrates the rich features and versatile composition of the Eclipse IDE:

Figure 19. Features of the Eclipse IDE user interface made available to allplug-ins

Uniform developer experience across platforms

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 39 of 69

Page 40: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 40/69

Eclipse's all-Java construction lets exactly the same IDE code and IDE userinterface run on any supported OS and hardware platform. Once you becomefamiliar with the UI and operations of Eclipse, you will be right at home on anydevelopment platform, including UNIX, Linux, Windows, Mac OS X, and others.

Section 12. Downloading and installing Eclipse

In this section, you'll download and install the Eclipse IDE and the Eclipse WTPserver adapter for Application Server.

Downloading Eclipse

You can download releases of the Eclipse IDE for your platform from the EclipseProject Downloads page.

The Eclipse WTP server adapter for Application Server that you'll use for this tutorialhas been tested on Eclipse 3.3 (Europa) and Eclipse WTP 2.0.1. Make sure youdownload only the compatible binaries.

Instead of downloading and installing Eclipse, then WTP, then all the dependenciesseparately, you can use an all-in-one binary download to save time and avoidheadaches. Follow the links for the latest release at the Web Tools Platform

downloads page to download a compatible version of the all-in-one binaries. Therelease version that this tutorial is tested on is based on WTP 2.0.1, and thedownload is wtp-all-in-one-sdk-R-2.0.1-20070926042742-win32.zip.

Unzip and install the Eclipse WTP all-in-one distribution

Installing Eclipse is as simple as unzipping the .zip file's contents to a directorywhere you want Eclipse to be installed. Make sure you maintain the .zip file'sstructure as you unzip the distribution.

If you look into your distribution directory, you will find an eclipse.exe executable,which starts Eclipse. You might want to drag-and-drop a shortcut onto your desktopor the system tray to make future launching of the IDE simpler.

Double-click eclipse.exe or run it on the command line. The IDE should start. Afterthe splash screen, it prompts you to select a workspace , shown in Figure 20:

Figure 20. Selecting the initial workspace for the Eclipse IDE

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 40 of 69

Page 41: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 41/69

A workspace is simply a directory where Eclipse manages source code and otherartifacts for your projects. You can maintain as many projects as you wish in aworkspace. In production projects that use version control, development staff oftenneeds to work on multiple branches of the same source tree at the same time. Youcan use multiple workspaces to work on the different branches. For the purpose ofthis tutorial, accept the default to let Eclipse create a new workspace for you.

The IDE starts up with a help screen that lets you walk through the fundamentals ofworking with Eclipse, if you wish. Close Eclipse to prepare for the next step.

Eclipse WTP server adapter for Application Server installation

The Eclipse WTP server adapter for Application Server lets you control an instanceof Application Server within Eclipse. You can automate the testing/debug processusing this server adapter because it can also install and uninstall applicationsdirectly to the connected instance of the Application Server. The best way to installthe Eclipse WTP server adapter for Application Server is to use the Eclipse update

manager. Using the update manager significantly simplifies the download andinstallation process.

To install the Eclipse WTP server adapter for Application Server:

1. Select Help > Software Updates > Find and Install ... from the Eclipsemenu.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 41 of 69

Page 42: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 42/69

2. In the Install/Update wizard, select Search for new features to installand click Next.

3. Click the New Remote Site button on the top right, and enter the name ofEclipse WTP server adapter for WAS CE 2.0, and set the URL tohttp://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/.

4. Expand the selection and make sure you are including only the 2.0 serveradapter — not any of the 1.1 adapters, which have completely differentdependencies.

5. Click Finish and let the update manager download and install theadapter.

After installation, the download manager might suggest a restart of the Eclipseenvironment. Let the update manager restart the environment, and the adapter will

be installed and ready to go.

Section 13. Hands-on Eclipse: Connecting Eclipse toDB2 Express-C 9.5

This section shows how to use Eclipse's powerful Data Source Explorer view to

connect to the DB2 Express SAMPLE database you created earlier in this tutorial.

Creating a DB2 Express-C 9.5 connection in the Data SourceExplorer

Start Eclipse in the workspace you created during the installation. From the EclipseIDE menus, select Window > Show View > Others....

In the window, select the Connectivity > Data Source Explorer view, as shown inFigure 21:

Figure 21. Creating an Eclipse Data Source Explorer view

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 42 of 69

Page 43: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 43/69

A new Data Source Explorer view appears. Right-click the Database element andselect New.... In the New Connection Profile wizard, select Generic JDBCConnection, and then click the Next button.

Fill in the connection information as shown in Figure 22, pointing to your SAMPLEdatabase:

Figure 22. Connecting Eclipse to DB2 Express-C 9.5 through the JDBC driver

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 43 of 69

Page 44: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 44/69

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 44 of 69

Page 45: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 45/69

Page 46: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 46/69

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 46 of 69

Page 47: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 47/69

You can see how easy it is to access information on DB2 Express-C 9.5 databasesfrom Eclipse.

Section 14. Working with data in the Data Output andDatabase Explorer views

Now that the connection to your DB2 database is established, you'll see some of thepowerful features provided by the Database Explorer and Data Output views inEclipse.

Examining table schema

In Figure 23, you saw that the Data Source Explorer provides full field definition, fieldtype, default values, and primary key information — right in the tree-view display ofthe PRODUCTS table.

Viewing the table content

To see the contents of a table (EMPLOYEE, for example), right-click the table andselect Data > Sample Content. This performs a SELECT * on the table anddisplays the result in an SQL Result view, as shown in Figure 24:

Figure 24. Eclipse SQL Results view displaying DB2 Express-C 9.5 tablecontents

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 47 of 69

Page 48: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 48/69

To see the SQL statement that is executed on the DB2 engine, you can click theStatus tab of the SQL Results view.

Modifying table content

You can change the value of any record, or add rows to a table, directly from theDatabase Explorer view. Right-click the EMPLOYEE table and select Data > Edit.

Eclipse opens up a database edit view. You can see all the data in the table. You

can change the data in the fields, and you can add new rows to the end of the table.Figure 25 shows this editable view:

Figure 25. Modifying DB2 Express-C 9.5 data from Eclipse

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 48 of 69

Page 49: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 49/69

Generating Data Definition Language (DDL) for your table

Another useful feature available in Database Explorer view is the ability to generateData Definition Language (DDL) scripts from your connected databases. To see thisin action, right-click EMPLOYEE and select Data > Generate DDL....

This brings up a wizard that guides you through the DDL generation process. Selectall the check boxes in the wizard's first two screens. The wizard's final screenpreviews the generated DDL. For the EMPLOYEE table, it is similar to Listing 3:

Listing 3. DDL generated by Eclipse's Database Explorer for the EMPLOYEEtable

ALTER TABLE "SING"."EMPLOYEE" DROP CONSTRAINT "RED";

...

CREATE TABLE "SING"."EMPLOYEE" ("EMPNO" CHAR(6) NOT NULL,"FIRSTNME" VARCHAR(12) NOT NULL,"MIDINIT" CHAR(1),"LASTNAME" VARCHAR(15) NOT NULL,"WORKDEPT" CHAR(3),"PHONENO" CHAR(4),

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 49 of 69

Page 50: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 50/69

Page 51: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 51/69

In Figure 26, Eclipse's Database Explorer and Data Output views are used to accessdirectly the database schema and content managed in DB2 Express-C 9.5.Application Server is configured with a JDBC data pool that accesses DB2Express-C 9.5 databases.

Creating a new Eclipse project

Follow these steps to create a new Web project for Application Server deployment:

1. Shut down your Application Server instance.

2. Start Eclipse and select File > New > Project... from the applicationmenu.

3. From the window, select Web > Dynamic Web Project.

4. In the wizard screens:

• Enter dwapp for the Project name.

• Select IBM WASCE v2.0 for the Target Runtime.

• Point the server directory to where you've installed Application Server.

Figure 27 shows the wizard used to create a new dynamic Web project.

Figure 27. Creating a new dynamic Web project on the Eclipse IDE

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 51 of 69

Page 52: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 52/69

Generated deployment descriptor and plan

Web applications are archived into standard WAR file format before they can bedeployed to a compatible server. The organization of these WAR files is governed bythe Java EE 5 standard specifications.

The wizard has also generated two XML files automatically, described in Table 5:

Table 5. Wizard-generated XML files for Java EE 5 dynamic Web applications

Generated XML file Description

WEB-INF/web.xml Standard J2EE deployment descriptor for Web

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 52 of 69

Page 53: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 53/69

Page 54: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 54/69

Other....

2. From the wizard, select Web > JSP.

3. Name the page index.jsp.

4. Click Finish.

Eclipse generates a skeletal JSP page from a template. Edit the page to matchListing 4. Alternatively, you can copy the source from this tutorial's code download(see Download).

Listing 4. JSP accessing employee data from the DB2 Express-C 9.5 SAMPLEdatabase

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><link rel="stylesheet" type="text/css" href="dwstyles.css"/><title>dW Example Employee Data from DB2 Express-C 9.5 Table</title></head><body>

<h1>&nbsp;&nbsp;DB2 Express Employee List</h1><br><table><tr>

<th>Emp no</th><th>First name</th><th>Last name</th><th>Phone</th><th>Job</th><th>Salary</th><th>Bonus</th><th>Commission</th><th>Department</th>

</tr>

<sql:query var="employees" dataSource="jdbc/DataSource">SELECT * FROM EMPLOYEE</sql:query>

<c:forEach var="employee" items="${employees.rows}"><tr>

<td><c:out value="${employee.empno}"/></td><td><c:out value="${employee.firstnme}"/></td><td><c:out value="${employee.lastname}"/></td>

<td><c:out value="${employee.phoneno}"/></td><td><c:out value="${employee.job}"/></td><td><c:out value="${employee.salary}"/></td><td><c:out value="${employee.bonus}"/></td><td><c:out value="${employee.comm}"/></td><td><c:out value="${employee.workdept}"/></td>

</tr></c:forEach>

</table></code>

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 54 of 69

Page 55: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 55/69

</body></html>

This JSP prints out a table of employee information. Each row displayed representsone employee record maintained in the DB2 Express-C 9.5 EMPLOYEE table.

The coding makes use of only JSP Standard Tag Library (JSTL) tags andExpression Language (EL); it does not contain any embedded Java code.Embedded Java code in JSP is often viewed as a bad practice because it tends tobecome error-prone and unmanageable in the long term.

The boldfaced lines in Listing 4 show how the <sql:query> tag accesses a JDBCdata source called jdbc/DataSource to execute the SQL SELECT statement. Theresult of the query is assigned to the employees variable. Each row of this result isthen displayed using a <c:forEach> iterative tag.

Linking an application data source reference to an ApplicationServer database pool

The index.jsp page, when deployed to Application Server, needs to resolve the datasource named jdbc/DataSource. Specifically, you need to make sure that itresolves to the dwDatasource that you set up earlier, which points to the DB2Express-C 9.5 SAMPLE database.

This is standard Java EE flexibility. The deployable application WAR file containsreferences to resources (such as a data source) that is resolved only when theapplication is deployed. This enables the same code module to be deployed, without

reassembly, on different application servers against different database servers.

Examine the web.xml file that is generated and make sure you add the boldfacedlines from Listing 5. (You might need to click the Source tab of the Eclipse XML fileeditor.) Make sure you save the updated web.xml file.

Listing 5. Java EE deployment descriptor web.xml for the application

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5">

<display-name>dwapp</display-name><welcome-file-list>

<welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file>

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 55 of 69

Page 56: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 56/69

<welcome-file>default.jsp</welcome-file></welcome-file-list>

<resource-ref><res-ref-name>jdbc/DataSource</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth><res-sharing-scope>Shareable</res-sharing-scope></resource-ref>

</web-app>

The <resource-ref> provides information to the container (Tomcat in this case)on the external resource references that need to be resolved.

In the geronimo-web.xml file, you make the actual link to the dwDatasource.Examine the geronimo-web.xml deployment plan in Eclipse. (Click the Source tab ofthe deployment plan editor.) Add the boldfaced lines shown in Listing 6 to thedeployment plan and save it:

Listing 6. The Application Server specific deployment plan geronimo-web.xml

<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2"

xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2"xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">

<sys:environment><sys:moduleId>

<sys:groupId>default</sys:groupId><sys:artifactId>dwapp</sys:artifactId><sys:version>1.0</sys:version><sys:type>car</sys:type>

</sys:moduleId>

<sys:dependencies><sys:dependency>

<sys:groupId>console.dbpool</sys:groupId><sys:artifactId>dwDatasource</sys:artifactId>

</sys:dependency></sys:dependencies>

</sys:environment><context-root>/dwapp</context-root>

<resource-ref><ref-name>jdbc/DataSource</ref-name><resource-link>dwDatasource</resource-link>

</resource-ref>

</web-app>

Adding a <sys:dependency> pointing to console.dbpool/dwDatasourceensures that the JCA 1.5 resource adapter instance that you configured earlier isavailable to this application. Note that if <sys:version> and <sys:type> of the<sys:dependency> are not specified, Application Server will treat this as awildcard and look up the resource matching any version or type. The<nam:resource-ref> element tells Tomcat in Application Server that thejdbc/DataSource reference should be linked to the configured dwDatasource

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 56 of 69

Page 57: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 57/69

database pool.

Application Server as a Web server: Adding static content

So far you've learned how to generate content dynamically by executing JSP codeon Application Server. But Application Server also has the built-in capability to act asa regular Web server that serves static content.

If your Web project requires static content service, just place the static contentstarting from the WebContent directory in your Eclipse project.

Right-click the WebContent directory and select New > Other.... From the pop-upwindow, select Web > CSS. You'll add a static Cascading Style Sheet (CSS) to theapplication to enhance its appearance. Name the stylesheet dwstyles.css andaccept the default template for the stylesheet.

Edit the dwstyles.css file, adding the content in Listing 7. You can alsocopy-and-paste from the code distribution (see Download).

Listing 7. dwstyles.css A static stylesheet for formatting the data output

h1 {font-family: arial;font-size: 38;align: left;font-weight: bold;font-style: italic;color: green;

}

th {font-family: verdana, arial;font-size: 13;font-weight: bold;align: left;background-color: black;color: white;

}

td {font-family: verdana, arial;font-size: 12;font-style: italic;align: left;

}

table {border-style: solid;border-width: thin;

}

Save the modified stylesheet. When you deploy the application, the stylesheet isaccessible directly, as static content, from Application Server. Your user's browseraccesses this static stylesheet to format the dynamic output from index.jsp.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 57 of 69

Page 58: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 58/69

If the first page of your Web project is static and not dynamically generated, you cansimply add an index.html page to the WebContent directory.

Deploying applications to Application Server

Alternative way to deploy applicationsAn alternative way of deploying the application to Application Serveris to export the project as a WAR file and then deploy it using theApplication Server console. To export a WAR file, right-click on thedwapp project and select Export.... In the Export Wizard, selectWeb > WAR file. Save the exported WAR file to a directory of yourchoice where it can be found easily. Then, with the ApplicationServer running:

1. Log in to the console.

2. Select Deploy New from the menu.

3. Click the Browse button and locate the WAR file.

4. Click Install to deploy and start the application.

You are now ready to deploy the dwapp application to Application Server.

Right-click the dwapp element in Eclipse's Navigator and select Run as > Run onServer....

In the Run On Server wizard that opens (shown in Figure 29), select IBM WASCEv2.0 Server. Make sure you select the check box named Always use this serverwhen running this project.

Figure 29. The Run On Server wizard connecting Eclipse to a ApplicationServer instance

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 58 of 69

Page 59: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 59/69

Click Next and select the JRE that you are using. (It must be one of the JRE

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 59 of 69

Page 60: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 60/69

releases listed in System requirements). Also enter the directory where you haveinstalled Application Server. This is shown in Figure 30:

Figure 30. Specifying JRE and Application Server runtime for the Eclipseconnected server

Click Finish and wait while Eclipse starts Application Server and deploys theapplication to Application Server.

Start a browser and point it to the URL http://localhost:8080/dwapp/ 

You should see the list of employees displayed on a Web browser window within theEclipse IDE, as shown in Figure 31:

Figure 31. Successful Eclipse deployment of an Application Server applicationaccessing DB2 Express-C 9.5 data

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 60 of 69

Page 61: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 61/69

The IDE is now connected to Application Server for rapid development anddeployment. At any time during your development cycle, you can deploy yourapplication to Application Server for testing. If you wish, you can configure the sameApplication Server for production. Your application users can then see yourapplication changes immediately after you deploy the application to the server.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 61 of 69

Page 62: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 62/69

Section 16. Configuring Application Server for anInternet Web site

So far, this tutorial has focused the setup for Application Server on ease ofapplication development and test deployment. In this section, you'll configureApplication Server as a general Web server on the Internet.

Application Server as a Web server

If your machine were set up as an Internet-accessible server, the users accessingyour application over the Internet would need to use the URL http:// your www domain name :8080/ your application name . Now you'll learn how to configure

Application Server to accept the URL http:// your Web domain name  /.

It involves two steps:

1. Changing the TCP port that the Tomcat (Web connector) listener islistening to.

2. Changing the application context of the application deployed onApplication Server.

Changing the Tomcat listener port

You need to change the Application Server default port 8080 assignment to port 80.Port 80 is the default TCP port for the HTTP protocol. If you use port 80 on theApplication Server, users do not need to specify explicitly the port when they accessyour site.

Log on to the Application Server Administrative Console and select Web Server onthe left-hand side menu. You'll see three connectors running: one for SecureSockets Layer (SSL)-based connections, one for the AJP protocol for connecting tofront-end Web servers, and one for regular Web connections via the HTTP protocol.Click the edit link next to the HTTP-based TomcatWebConnector. On the nextscreen, replace port 8080 with port 80 and click Save. Figure 32 shows the editedTomcatWebConnector:

Figure 32. Changing the port of the TomcatWebConnector for Internet useraccess

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 62 of 69

Page 63: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 63/69

Now, shut down the server and restart it. Your Application Server application is nowaccessible at http:// your WWW domain name  / your application name .

Next, to eliminate the need to type the name of the application, you'll modify the

application deployment context to map to the root or /.

Modifying the application deployment context

To map the application deployment context root to /, you need to modify thegeronimo-web.xml deployment plan in your project. The element you need to modifyis named <context-root>.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 63 of 69

Page 64: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 64/69

For example, if you want to move the dwapp application to the root context, youneed to make the change shown in boldface in Listing 8 to its geronimo-web.xmlplan:

Listing 8. Modifying geronimo-web.xml to deploy application at server root

<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2"

xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2"xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">

<sys:environment><sys:moduleId>

<sys:groupId>default</sys:groupId><sys:artifactId>dwapp</sys:artifactId><sys:version>1.0</sys:version><sys:type>car</sys:type>

</sys:moduleId><sys:dependencies>

<sys:dependency>

<sys:groupId>console.dbpool</sys:groupId><sys:artifactId>dwDatasource</sys:artifactId>

</sys:dependency></sys:dependencies>

</sys:environment>

<context-root>/</context-root>

<resource-ref><ref-name>jdbc/DataSource</ref-name><resource-link>dwDatasource</resource-link>

</resource-ref></web-app>

Disabling the default welcome application at server root

Application Server maps a welcome application by default to the context root /. Inaddition to modifying the geronimo-web.xml plan, you must disable this application.Otherwise, Application Server will report an error trying to map the context root. Todisable the welcome application:

1. Click the Expert User checkbox at the top of the screen.

2. Click the Applications > Web App WARs link in the left menu.

3. Locate the links next to the component namedorg.apache.geronimo.configs/welcome-tomcat/2.0.1/car.

4. Click the Stop link.

Figure 33 shows a disabled welcome application:

Figure 33. Stopping the default welcome application

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 64 of 69

Page 65: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 65/69

Section 17. Summary

You are at an historical moment in the evolution of the software industry. As a JavaWeb developer, you now have a choice of many free servers and development toolsthat a few short years ago were available to only the largest enterprise developmentteams.

The open source Eclipse IDE, the IBM DB2 Express-C 9.5 database, and IBM

WebSphere Application Server Community Edition 2.0 are all your disposal, only ashort click away. This collection of servers and IDEs works well together to makeyour design, development, testing, and deployment life simpler.

In this tutorial, you have:

• Installed and became familiar with DB2 Express-C 9.5, using its rich set ofGUI tools and command-line tools.

• Created database tables with DB2 Express-C 9.5 and queried againstthem using SQL commands.

• Installed and worked with WebSphere Application Server CommunityEdition, using its Web-based Administrative Console as well as thecommand-line deployer tool.

• Connected WebSphere Application Server Community Edition to DB2Express-C 9.5 by deploying a system-wide database pool to the DB2database.

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 65 of 69

Page 66: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 66/69

• Installed the Eclipse IDE, the supporting Web Tools Platform, and theEclipse WTP server adapter for WebSphere Application ServerCommunity Edition.

• Connected Eclipse to DB2 Express-C 9.5 through Eclipse's versatile

Database Explorer view, which lets you view schema structure, see tabledata content, modify data, and generate DDL.

• Used Eclipse to create a Web application and deployed it to WebSphereApplication Server Community Edition with one click, supported throughthe Eclipse WTP server adapter for WebSphere Application ServerCommunity Edition.

• Successfully developed an application on Eclipse, deployed it toWebSphere Application Server Community Edition, and made theapplication use DB2 Express-C 9.5 as its data supplier.

• Configured WebSphere Application Server Community Edition for accessby users over the Internet.

You are now well on your way to developing and deploying your own Webapplications on this powerful collection of software server and tools.

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 66 of 69

Page 67: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 67/69

Downloads

Description Name Size Downloadmethod

Sample code for this tutorial j-kickstartcode.zip 4KB HTTP

Information about download methods

ibm.com/developerWorks developerWorks®  

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 67 of 69

Page 68: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 68/69

Resources

Learn

• "DB2 Express-C, the developer-friendly alternative" (Grant Hutchison,

developerWorks, February 2006): Get started quickly using DB2 Express-C forall of your applications.

• Migrate to DB2 Express-C: Resources to help you get started migrating to DB2Express-C today.

• Get started now with Eclipse: The developerWorks Eclipse resource page.

• "Manage your Eclipse environment" (Chris Aniszczyk and Phil Crosby,developerWorks, February 2006): Zen and the art of Eclipse maintenance.

• Migrating to Eclipse: A developer's guide to evaluating Eclipse: Find out howEclipse differs from Netbeans, IntelliJ IDEA, and Borland JBuilder.

• "Developing Eclipse plug-ins" (David Gallardo, developerWorks, December2002): Learn to create, debug, and install your plug-ins.

• WebSphere Application Server Community Edition: Documentation, FAQs,articles, and more resources.

• Apache Geronimo: The Java EE server from Apache.

• Apache Axis: Apache's reliable and stable base for implementing Java Webservices.

• Apache Tomcat: The Apache servlet container that is used in the official

Reference Implementation for the Java Servlet and JavaServer Pagestechnologies.

• Apache Derby: Apache's relational database implemented entirely in Java.

• ActiveMQ: Try out this fast, open source JMS 1.1 provider, which supportsclustering, peer networks, discovery, TCP, SSL, multicast, persistence, and XAand integrates seamlessly into Java EE 5 containers, lightweight containers,and any Java application.

• Open EJB: Learn more about this open source, modular, configurable, andextendable EJB Container System and EJB Server.

• Yoko: An open source Java CORBA server implementation.

Get products and technologies

• WebSphere Application Server Community Edition: Download the applicationserver.

• DB2 Express-C: Download the database server.

developerWorks® ibm.com/developerWorks

Free software, fast development Trademarks © Copyright IBM Corporation 2006, 2007. All rights reserved. Page 68 of 69

Page 69: j Kickstart PDF

8/8/2019 j Kickstart PDF

http://slidepdf.com/reader/full/j-kickstart-pdf 69/69

• Eclipse: Download the Eclipse SDK. Get the all-in-one Eclipse binary downloadfrom the Web Tools Platform downloads page.

• Application Server WTP Server Adapter: Follow these step by step instructionsto install the server adapter.

Discuss

• DB2 Express forum

• eclipse.org

• Eclipse newsgroups

• Eclipse developer mailing lists

• developerWorks blogs

About the author

Sing Li

Sing is a consultant and an active author with over two decades ofindustry experience. He has contributed to Beginning JavaServer Pages , Professional Apache Tomcat 5 , Pro JSP - Third Edition , Early Adopter JXTA, Professional Jini, Beginning J2ME: From Novice to Professional, Third Edition  , and numerous other books. Sing alsowrites for technical magazines and participates in open sourcecommunities. He is an evangelist of the open source, VOIP, and P2P

movements. You can reach Sing at [email protected].

ibm.com/developerWorks developerWorks®