DataSource objects, as defined in the JDBC 2.0 Standard Extension specification, let you manage a pool of connections to a database. The chief advantages of using a connection pool are:
- Saves time. Creating connections is expensive; with a connection pool, the data source maintains a pool of connections and provide connections to the clients at request time.
- Simplifies resource allocation. Resources are only allocated from the DataSource objects, not at arbitrary places in the code.
- Simplifies connection calls. To get a connection in JDBC 1.0, you must call Class.forName() on the classname of the database driver before making DriverManager calls. With JDBC 2.0, on the other hand, you have the option to get an instance of a data source with a JNDI lookup and then get a connection from the DataSource instance by calling its getConnection() method. The code is more portable.
WebSphere Application Server Version 5 supports two kinds of data sources:
- Version 4 data sources for applications that are written according the J2EE 1.2 specification.
- Version 5 data sources for applications that are written according the J2EE 1.3 specification.
IBM® DB2® Universal DatabaseTM (UDB) family products are seamlessly integrated with WebSphere Application Server. This article will focus on how to configure a Version 5 data source for the DB2 UDB family of products in WebSphere Studio v5. WebSphere Studio is a development tool for J2EE applications with both v4 and v5 Test Environments of WebSphere Application Server. Because the WebSphere Test Environment is actually a WebSphere Application Server base version embedded in WebSphere Studio, you can use the same configuration steps for the actual WebSphere Application Server Admin Console. This article specifically uses the Application Developer Configuration of WebSphere Studio.
The following DB2 family products are covered in this article:
- DB2 UDB for distributed platform (Windows®, Linux, and UNIX®,)
- DB2 UDB for iSeries
- DB2 UDB for z/OS and OS/390
Configuring a data source in WebSphere® Studio
In WebSphere Studio, you define a DataSource in the server configuration file of WebSphere Test Environment. The following four steps describe how to configure a DataSource in WebSphere Studio after you have created a server configureation. Refer to the online help of WebSphere Studio for information about creating a server configuration.
- Decide on the scope.
A DataSource can be defined in multiple scopes, which are the levels to which this resource definition is visible -- the cell, node, or server level.
Figure 1. Choose the scope of the DataSource
Cell A cell is a group of nodes in a WebSphere Application Server distributed network that are associated with each other. Resources defined at the cell scope are visible from all nodes and servers, unless they are overridden. Because the WebSphere Test Environment in WebSphere Studio only supports one node, the option for cell is not available. The WebSphere Application Server Network Deployment version does have the Cell option.
Node A node is a physical machine, which may contain multiple server instances. Resources defined at the node scope override any duplicates defined at the cell scope and are visible to all servers on the same node, unless they are overridden at a server scope on that node.
Server Resources defined at the server scope override any duplicate resource definitions defined at the cell scope or parent node scope and are visible only to a specific server. "Server" is the default scope in WebSphere Test Environment. - Create a JDBC provider.
To create a JDBC provider, you must know the implementation class of the DataSource interface, and the class path of the JDBC driver, both of which are vendor-specific. For example, the implement class for a DB2 UDB DataSource is
COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource, which is part of the JDBC driverdb2java.zip. - Create a data source.
A DataSource has many properties. The following properties are vendor-neutral:
Name Specifies the display name for the data source. For example, you can use the name TestDataSource.
JNDI name Specifies the Java Naming and Directory Interface (JNDI) name. For example, you can use the name jdbc/TestDataSource. If you leave this field blank a JNDI name is generated from the name of the data source. For example, a data source name of TestDataSource generates a JNDI name of jdbc/TestDataSource.
Description Assigns a text description for the resource.
Category Specifies a category string you can use to classify or group the resource.
Statement cache size Specifies the number of free prepared statements that are cached per connection.
Datasource helper classname Specifies the datastore helper that is used to perform database-specific functions. This helper is used by the Relational Resource Adapter at runtime. The default DataStoreHelper implementation class is set based on the JDBC driver implementation class, using the structure:
com.ibm.websphere.rsadapter.<database>DataStoreHelper
For example, if the JDBC provider is DB2, then the default DataStoreHelper class iscom.ibm.websphere.rsadapter.DB2DataStoreHelper. You can change to your subclass of this DataStoreHelper if necessary.
Connection timeout Specifies the interval, in seconds, after which a connection request times out and a ConnectionWaitTimeoutException is thrown.
Maximum connections Specifies the maximum number of physical connections that can be in the pool.
Minimum connections Specifies the minimum number of physical connections to maintain in the pool.
Reap time Specifies the interval, in seconds, between runs of the pool maintenance thread.br/Unused timeout Specifies the interval in seconds after which an unused or idle connection is discarded.
Aged timeout Specifies the interval in seconds before a physical connection is discarded.
Purge policy Specifies how to purge connections when a "stale connection" or "fatal connection error" is detected. Valid values are EntirePool and FailingConnectionOnly.
Component-managed authentication alias In the server configuration editor of WebSphere Studio, you can use the Security tab to define a Java Authentication and Authorization Extension (JAAS) alias for a username and password to connect to the backend Enterprise Information Systems (EIS). If the resource authentication (res-auth) in the deployment descriptor of the Web application or EJB application is set to "Application7" (as shown in Figure 2) and if the component-managed authentication alias the DataSource is specified, the alias for the username and password will be used for database authentication at run time.
Figure 2. Setting the authentication to "Application" in the deployment descriptor
Container-managed authentication alias This is similar to the component-managed authentication alias. If the resource authentication (res-auth) of the Web application or EJB application is set to "Container" (as shown Figure 3) and if the container-managed authentication alias of the DataSource is specified, the alias for username and password will be used for database authentication at run time.
Figure 3. Setting the authentication to "Container" in the deployment descriptor
Container-managed persistence Specifies whether this data source is used for container-managed persistence of enterprise beans. If the checkbox is selected, a CMP Connector Factory that corresponds to this data source is created for the relational resource adapter. - Specify additional resource properties.
Some of the properties of DataSource are vendor-specific. The required additional resource property for Type 2 JDBC driver is databaseName; the required additional resource properties for IBM Type 4 Universal JDBC driver for DB2 UDB for distributed platforms v8 and DB2 UDB for OS/390 and z/OS V6 and later are dataBaseName, driverType, serverName, and portNumber; the required additional resource property for JTOpen Type 4 JDBC driver for DB2 UDB for iSeries is serverName. Details are described in the following sections.
Case 1: Create a DataSource for DB2 for distributed platforms
We've described what is needed to create a DataSource in WebSphere Studio. This section provides an example of creating a DataSource for DB2 for distributed platforms.
The Type 2 driver is available for all versions of DB2 UDB. Figure 4 explains the connectivity between the Type 2 JDBC driver and DB2 UDB for distributed platforms.
Figure 4. Connectivity between Type 2 JDBC driver and DB2 for distributed platforms

If WebSphere Studio and DB2 are installed in the same machine, the DBC Client CLI can talk to the database through DRDA directly. For example, many users of WebSphere Studio have Studio and DB2 Personal Edition on their Windows machines. DB2 Connect is not needed in this case.
However, in a team development environment, developers mostly share the database resources in a centralized server. In this case, you must have DB2 Connect on the workstations on which WebSphere Studio is installed, and you must create a database alias of the remote database in DB2 Connect. The remote database will act like a local one after the alias is created and is transparent to the Java application and the DataSource definition.
This article does not cover the details of creating the alias for DB2 for distributed platforms because the steps are self-explanatory. The following steps to create a DataSource for DB2 for distributed platforms are the same no matter whether the database resides locally or remotely, assuming that you create an alias in DB2 Connect or the DB2 UDB Client Configuration Assistant if the database is a remote one.
This section assumes you already have WebSphere Studio Application Developer installed and with the WebSphere Test Environment version 5.0 set up. Open the WebSphere Test Environment server configuration into an editor and you can setup the datasource using the following steps:
- Create a JAAS alias.
Open the server configuration in the editor, click on the Security tab. Scroll down the window until you see JAAS Authentication Entries. Click the Add button.
Give a name for the alias, for example, DB2 user, and then fill in the appropriate user ID and password for the database as shown in Figure 5. Click OK.
Figure 5. Create a JAAS authentication alias
- Create a JDBC provider.
Switch to the DataSource tab. A Default DB2 JDBC Provider is included in the JDBC provider list. Highlight the Default DB2 JDBC Provider in the list. Click on the Edit button. The settings of the JDBC Provider looks like Figure 6.
Figure 6. Create a JDBC provider
As you can tell,
DB2_JDBC_DRIVER_PATHis a variable. In most cases, WebSphere Studio can detect the value of the variable if you have DB2 Connect or DB2 UDB installed in the same box. For example, if you install DB2 inC:\Program Files\SQLLIB, the value ofDB2_JDBC_DRIVER_PATHwill be set toC:\Program Files\SQLLIB\java. You can manually set the variable by clicking the Variables tab of the server configuration and editing the value ofDB2_JDBC_DRIVER_PATH, as shown in Figure 7.
Figure 7. Set the JDBC path variable
- Create the data source.
From the JDBC provider list, highlight the Default DB2 JDBC Provider, and then click the Add button in the second pane. Choose DB2 JDBC Provider as the type of JDBC provider and Version 5.0 as the data source type and click Next.
In the next window, you can configure the common properties for the data source. You might want to customize the name, JNDI name and the description. If your database is not a local one, specify either the component-managed authentication alias or the container-managed authentication alias from the drop-down list, as shown in Figure 8, depending on the res-auth settings in the deployment descriptor of your application. Click Next.
Figure 8. Specify the properties for the data source
- Specify the custom properties.
In the Modify Resource Properties dialog, you are only required to set the databaseName property. Highlight the databaseName attribute and make sure it is pointed to the right database name (or database alias name if it resides in a remote server) as shown in Figure 9. Click Finish.
Figure 9. Specify the database name
- Save the server configuration using CTRL+S.
Using Type 4 driver (new in Version 8)
DB2 UDB Version 8 introduces the Type 4 JDBC driver, which can talk directly to the server without DB2 Connect installed. Figure 10 shows the connectivity between the Type 4 JDBC Driver and DB2 UDB. The Type 4 JDBC driver supports DB2 UDB for distributed platforms v8 and DB2 UDB for OS/390 and z/OS v6 and later. This Type 4 driver does not support previous versions of DB2 UDB, nor does it support two-phase commit.
Figure 10. Connectivity between Type 4 JDBC driver and DB2 for distributed platforms

WebSphere Studio Version 5 does not currently have the tooling support for creating a DataSource using the Type 4 JDBC driver, although this support is planned for a future release of WebSphere Studio. To use the Type 4 driver with WebSphere Studio Version 5, you must specify the implementation class and custom properties by treating it as a user-defined JDBC driver.
Important: The Type 4 driver requires WebSphere Application Server 5.01 runtime, which at the time this article was written was not yet available for download.
The following steps guide you through the process:
- Open the server configuration editor in WebSphere Studio.
- Click on the Variables tab. Find the variable named DB2_JDBC_DRIVER_PATH and set its value to the JDBC driver folder of DB2 Version 8 installation; for example,
C:\Program Files\SQLLIB\java. You will notice that this variable is used in the JDBC provider definition in Step 7. - Click on the Security tab, and create a JAAS authentication alias with appropriate user ID and password for DB2.
- Click on the DataSource tab. Add a new JDBC Provider. Choose User-defined as the database type and choose User-defined JDBC Provider as the JDBC provider type. Click Next.
- Give a name to this JDBC provider, for example,
IBM Type 4 JDBC Provider for DB2 Version 8. - Set the implementation class name to
com.ibm.db2.jcc.DB2SimpleDataSource. - Remove
${User-defined_JDBC_DRIVER_PATH}/db2j.jarfrom the classpath. Add${DB2_JDBC_DRIVER_PATH}/db2jcc.jarinto the classpath, whereDB2_JDBC_DRIVER_PATHis a variable whose value we set in Step 2. Click Finish. - Add a DataSource. You might want to customize the name, JNDI name and the description. Select
com.ibm.websphere.rsadapter.DB2DataStoreHelperas the data source helper class name. Specify either the component-managed authentication alias or container-managed authentication alias with the JAAS authentication alias (defined in Step 3) from the drop-down list, depending on the res-auth settings in the deployment descriptor of your application. Click Finish. - Add the following required properties for the data source. The type for all these properties is
java.lang.String.
serverName Set the value to the hostname or IP address of your DB2 box.
portNumber Set the value to the TCP/IP port number the DB2 server listens for connection requests to this data source. The default value is 50000. You can change the listening port by using this command:db2 update dbm cfg using svcename portNumberWhere portNumber is the listening port, such as 50002.
DriverType Set the value to 4, which represents the Type 4 JDBC driver. - Save the server configuration with CTRL+S.
Case 2: Create a DataSource for DB2 for OS/390® and z/OSTM
Creating a DataSource for DB2 for z/OS using Type 2 JDBC driver is similar to creating a DataSource for DB2 for distributed platforms. You must use DB2 Connect or DB2 UDB Client Configuration Assistant to create a database alias in your local machine. Figure 11 shows the connectivity between the Type 2 JDBC driver and DB2 UDB for z/OS.
Figure 11. Connectivity between type 2 JDBC driver and DB2 for z/OS

However, creating the local alias for the remote database, which resides in z/OS is not as trivial as for DB2 for distributed platforms. The following steps help you understand how to configure the alias for DB2 UDB for z/OS in DB2 Connect.
- In the system log found under the system display and search facility (SDSF), locate the DSNL004I message and write down the DOMAIN, LOCATION, and TCPPORT listed. You will need this information later.
- Launch the DB2 Client Configuration Assistant on the Windows platform by clicking Start => Programs => IBM DB2 => Client Configuration Assistant.
- Click the Add... button to add a new database alias representing the database on the host machine.
- In the Add Database wizard, select the Source tab and select the Manually configure a connection to a database radio button. Click Next.
- Under the Protocol tab, click the TCP/IP radio button.
- Check the box for The database physically resides on a host or AS/400 system.
- Ensure that Connect directly to the server is selected. Click Next.
- Under the TCP/IP tab, enter the DOMAIN name from Step 1 in the Host name field.
- In the Port number field, enter the TCPPORT from Step 1. Click Next.
- Under the Database tab, enter the LOCATION from Step 1 in the Database name field. The Database alias field should be automatically populated with the same name. Click Next.
- Under the ODBC tab, uncheck Register the database to ODBC. Click Next.
- Under the Node Options tab, select the Configure node-options (Optional) checkbox and ensure that the Operating System drop down menu displays the MVS/ESA®, OS/390 value. Click Next.
- Under the Security Options tab, select the Configure security options (Optional) checkbox and the Host or AS/400 authentication (DCS) radio button. Click Next.
- Under the Host or AS/400 Options tab, uncheck Configure host or AS/400 options (Optional).
- Click the Finish button. A confirmation window should appear. Verify that a connection can be made to the host by clicking the Test Connection button in the Confirmation window.
- After the Connect To DB2 Database window appears, enter the appropriate user ID and password that has authority to bind the database.
- Wait for the DB2 Message window to appear, indicating "The connection test was successful." Click OK.
- Click Add... Verify that the database alias specified in Step 10 above has been added to the list of aliases displayed in the Available DB2 Databases table in the Client Configuration Assistant. Click Close.
After the database alias is created, follow the same steps described in Case 1 to create the data source in WebSphere Studio. Use the new database alias in the databaseName property in Step 4 of Case 1 using the Type 2 driver.
Using the Type 4 driver (for Version 6 and later)
The Type 4 JDBC driver that comes with DB2 UDB for distributed platforms v8 also supports connectivity to DB2 UDB for OS/390 and z/OS v6 and v7. The configuration for a DataSource for DB2 UDB for OS/390 and z/OS using the Type 4 JDBC driver is similar to the configuration for DB2 UDB for distributed platforms, as described in Case 1.
Case 3. Create a DataSource for DB2 for iSeriesTM
The Type 4 JDBC driver that comes with DB2 UDB for distributed platforms v8 also supports connectivity to DB2 UDB for OS/390 and z/OS v6 and v7. The configuration for a DataSource for DB2 UDB for OS/390 and z/OS using the Type 4 JDBC driver is similar to the configuration for DB2 UDB for distributed platforms, as described in Case 1.
As shown in Figure 12, the Type 2 JDBC driver requires DB2 Connect in the local box. The settings for the DataSource are much the same as described in Case 1. The only difference is creating the alias with DB2 Connect. The following steps help you configure the alias for DB2 UDB for iSeries in DB2 Connect.
Figure 12. Connectivity between the Type 2 JDBC Driver and DB2 for iSeries

- Log on to the AS/400® system. Run
WRKRDBDIREfrom the command line. You may see some database name there. But only the one marked with*LOCALis the local database that physically resides in this AS/400 system. Write down the Relational Database Name, which is Q1A_DATABASE_SRVR in Figure 13. You will need this information in Step 10 below.
Figure 13. Find the database name from the iSeries system
- Launch the DB2 Client Configuration Assistant on the Windows platform by clicking Start => Programs => IBM DB2 => Client Configuration Assistant.
- Click the Add... button to add a new database alias representing the database on the host machine.
- In the Add Database wizard, select the Source tab and select the Manually configure a connection to a database radio button. Click Next.
- Under the Protocol tab, click the TCP/IP radio button.
- Check the box for The database physically resides on a host or AS/400 system.
- Ensure that Connect directly to the server is selected. Click Next.
- Under the TCP/IP tab, enter the host name or IP address of your AS/400 box in the Host name field.
- Enter 446 in the Port number field. Click Next.
- Under the Database tab, enter the Relational Database name from Step 1 in the Database name field. The Database alias field is automatically populated with the same name. Click Next.
- Under the ODBC tab, uncheck Register the database to ODBC. Click Next.
- Under the Node Options tab, select Configure node-options (Optional) and ensure that the Operating System drop down menu displays the OS/400 value. Click Next.
- Under the Security Options tab, select Configure security options and Host or AS/400 authentication (DCS). Click Next.
- Under the Host or AS/400 Options tab, uncheck Configure host or AS/400 options (Optional).
- Click the Finish button. In the confirmation window, verify that a connection can be made to the host by clicking the Test Connection button.
- After the Connect To DB2 Database window appears, enter the appropriate user ID and password that has authority to bind the database.
- Wait for the DB2 Message window to appear, indicating "The connection test was successful." Click OK.
- Click Add... Verify that the database alias specified in Step 10 above has been added to the list of aliases displayed in the Available DB2 Database table in the Client Configuration Assistant. Click Close.
After the database alias is created, follow the steps described in Case 1 to create the data source in WebSphere Studio. Use the database alias in the databaseName property in Step 4 of Case 1.
Using the JTOpen Type 4 driver
The Type 4 driver is part of the JTOpen, an open-source Java toolbox released by IBM for manipulating the iSeries. As you can see from Figure 14, the JTOpen Type 4 JDBC driver does not require additional client support beyond that provided by the Java Virtual Machine and TCP/IP.
Figure 14. Connectivity between type 4 JDBC driver and DB2 for iSeries

These steps guide you through the configuration of DataSource for DB2 for iSeries with the JTOpen Type 4 driver.
- Download and unzip JTOpen from the link in the Resources section of this article. Assuming that you unzip JTOpen to
C:\JTOpen, you will find that thejt400.jarresides inC:\JTOpen\lib. - Open the server configuration editor in WebSphere Studio.
- Click on the Variables tab. Add a variable named
OS400_TOOLBOX_JDBC_DRIVER_PATHand set its value to the location ofjt400.jar, for example,C:\JTOpen\libif JTOpen is unzipped toC:\JTOpenfolder. You will notice that this variable is used in the JDBC provider definition later on. - Click on the Security tab, and create a JAAS authentication alias with the appropriate user ID and password for the AS/400 system.
- Click on the DataSource tab. Add a new JDBC Provider. Choose IBM DB2 as the Database type and choose DB2 UDB for iSeries (Toolbox) as the JDBC provider type. If you need the DataSource supports two-phase commit, choose DB2 UDB for iSeries (Toolbox XA) instead. Click Next.
- Give a name to this JDBC provider, for example, JTOpen AS400 DB2 JDBC Provider. You will see the implementation class name is automatically selected and the classpath of the implementation class has been set to ${OS400_TOOLBOX_JDBC_DRIVER_PATH}/jt400.jar, where OS400_TOOLBOX_JDBC_DRIVER_PATH is a variable the value of which we set in Step 3. Click Finish.
- Add a DataSource. You might want to customize the name, JNDI name and the description. Specify either the component-managed authentication alias or container-managed authentication alias with the JAAS authentication alias defined in Step 5 from the drop-down list (depending on the res-auth settings in the deployment descriptor of your application as described in Configuring a data source in WebSphere Studio). Click Next.
- In the next screen, the only required property is the serverName. Set it to the hostname or IP address of your AS400 system. You may also want to change other properties according to your need. Click Finish.
- Save the server configuration by CTRL+S.
Writing a Java example using a data source
Assuming that you have installed DB2 for Linux, UNIX, and Windows and created the SAMPLE database, you can download this sample code that uses DataSource. The code is in J2EE 1.3 EAR format, which you can import into WebSphere Studio and run it in the WebSphere Test Environment Version 5.
The Servlet test.servlet.DepartmentListServlet in the EAR file will list the all the records in the DEPARTMENT table. Listing 1 is a code snippet of the doGet() method of the Servlet.
Important: Listing 1 uses the SQL statement SELECT * FROM DEPARTMENT, which doesn't have the qualifier for the table. If your ID used to connect to the database is different from the creator of the table DEPARTMENT, you need to add the creator user ID to the table name in the SQL statement.
Listing 1. doGet() method in sample code
java.sql.Connection connection = null;
java.sql.ResultSet rs = null;
try {
// Locate the naming initial context
javax.naming.InitialContext ctx =
new javax.naming.InitialContext();
/* perform a JNDI lookup for the DataSource. The JNDI name in the
code is a resource reference and is not necessary the same as the
JNDI name you defined for the DataSource. You need to bind this
resource reference to the real JNDI name in the deployment
descriptor . Please follow the installation instruction. */
javax.sql.DataSource myDS =
(javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/MyDS");
// create a connection from the DataSource
connection = myDS.getConnection();
// create a query from the connection
java.sql.Statement query = connection.createStatement();
/* create the result set. You probably need to add the qualifier
to the table name in the SQL statement */
rs = query.executeQuery("SELECT * FROM DEPARTMENT");
/* the following code print out all the items*/
java.io.PrintWriter out = resp.getWriter();
out.println("<HTML><HEAD><Title>Department List</Title></HEAD>");
out.println("<BODY><H2>DEPARTMENT LIST</H2>");
out.println("<table border='1' cellspacing='1' cellpadding='7'>");
out.println("<tr><td width='25%'>Department No</td>");
out.println("<td width='50%'>Department Name</td>");
out.println("<td width='25%'>Manager No</td>");
while (rs.next()) {
String deptNo = rs.getString("DEPTNO");
String name = rs.getString("DEPTNAME");
String mgrNo = rs.getString("MGRNO");
out.println("<tr><td width='25%'>" + deptNo + "</td>");
out.println("<td width='50%'>" + name + "</td>");
out.println("<td width='25%'>" + mgrNo + "</td>");
}
out.println("</table>");
out.println("</body></html>");
rs.close();
connection.close();
} catch (javax.naming.NamingException e) {
System.out.println("Name not found!");
System.out.println(e);
} catch (java.sql.SQLException e) {
System.out.println("SQLException!");
System.out.println(e);
} finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
System.out.println(
"Failed to close the ResultSet after the failure");
}
}
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
System.out.println(
"Failed to close the connection after the failure");
}
}
}
|
Follow these steps to run the sample code in WebSphere Studio:
- Import the EAR file into WebSphere Studio. You will see an enterprise project named DataSourceTest and a Web project named DataSourceTestWeb in the workspace.
- Create a Server Instance and Server configuration.
- Create a DataSource for the SAMPLE database. You can choose whatever JNDI name you want for the DataSource, for example,
jdbc/sample. Remember to close the editor when you are done. - If the ID used to connect to the database is different from the creator of the table DEPARTMENT, you need to add the creator user ID to the table name in the SQL statement in the servlet
test.servlet.DepartmentListServlet. - Open the Deployment Descriptor of the DataSourceTestWeb project. Click on the References tab. As shown in Figure 15, bind the DataSource reference
jdbc/MyDSin the Java code to the real global JNDI name of the DataSource you defined in Step 3. Save the Deployment Descriptor.
Figure 15. Binding the data source
- Add the enterprise project DataSourceTest project into the Server Configuration.
- Start the server.
- Enter
http://localhost:9080/DataSourceTestWeb/DepartmentListServletas the URL in the browser. You should be able to see the output as shown in Figure 16.
Figure 16. Sample database results
This article described the steps for configuring a data source in WebSphere Studio for the IBM DB2 Universal Database family of products. WebSphere Studio provides a great user interface for defining the DataSource in the server configuration editor. The IBM DB2 UDB family products are seamlessly integrated with the IBM WebSphere Runtime with the help of JDBC. Configuring DataSource with the Type 2 driver is consistent to all the family products. The one exception is that when you connect to iSeries or zSeries, you must create the alias for the remote database in DB2 Connect. IBM has a Type 4 JDBC driver, which supports connectivity to DB2 UDB for distributed platforms v8 and DB2 UDB for OS/390 and z/OS v6 and later. JTOpen also has a Type 4 JDBC driver for DB2 UDB for iSeries, which is recommended over the iSeries Type 2 driver.
| Name | Size | Download method |
|---|---|---|
| DataSourceTest.ear | 910 KB | HTTP |
Information about download methods
- Download JTOpen
- WebSphere Application Server Info Center
- DB2 Developer Domain
- WebSphere Developer Domain
- Hutchison, Grant."Developing Enterprise Java Applications Using DB2 Version 8", DB2 Developer Domain, September, 2002, at http://www.ibm.com/developerworks/db2/library/techarticle/0209hutchison/0209hutchison.html
Jane Fung works with the WebSphere Studio Application Developer Technical Support Team at the IBM Software Solutions Toronto Lab, Canada. You can reach Jane at jcyfung@ca.ibm.com.
Colin Yu is a technical designer on the business scenarios team at the IBM Toronto Lab. Colin received a Bachelor of Engineering degree in 1995 and a Master of Applied Science degree from the University of Waterloo, Ontario in 2000. He is an IBM Certified Enterprise Developer and Systems Expert on WebSphere Application Server, and an IBM Certified Solution Developer on WebSphere Studio Application Developer and VisualAge for Java. You can reach Colin at coliny@ca.ibm.com.
Comments (Undergoing maintenance)





