Connect to Java with DB2

To use JDBC DB2 in your Java application, you must first download and install a DB2 JDBC driver: db2jcc.jar 

Once downloaded, you must import the driver into Eclipse: put the driver's folder in your CLASSPATH variable or add the jar file to your project (Properties->Java Build Paths)
To import db2jcc.jar, click on the Window menu in Eclipse and select Preferences. In the resulting dialog box, choose Java then Buid Path then User Libraries. Click on New and define a library name, e.g., DB2LIBS. Then click Add JARs, navigate to the folder that contains db2jcc.jar and add the driver to the library.
Also add db2jcc.jar to tomcat's lib folder to enable the servlet to access the database.

To run your Web application, you would need to install Tomcat on your machine. 
The easiest way to debug and run your application is to install the Eclipse Tomcat plugin: 

Other DB2 links:

Stony Brook DB2 server: Click here

DB2 Express Server (needed if you want to set up a database on your own machine): 

DB2 Client (you need it to connect to DB2 remotely): 

Data studio: - Look under "Get free tools.“ 

Using Data Studio: 

DB2 University Training courses: 

DB2 9r7 Database Reference: Click on Database Reference in the left frame, then SQL, then Statements. For user-defined data types (UDTs), see CREATE TYPE (both row and structured). 

DB2 Application Developer's Guide. Version 7: - see Chapter 12 and 21.

The Developer Handbook: Chapter 2 (XML) and Chapter 5 (Java+XML)

Extremely pureXML in DB2 10 for z/OS: - Chapters 4, 5, 6.5(user-defined functions), 7.

Getting started with DB2 Express: Chapter 15 for XQuery

More examples of using XQuery and JDBC: