Monday, March 1, 2004

Creating a MySQL data source using WebSphere Application Server

DATABASE CONNECTIVITY

By Jeff Chilton
"Nothing can be done except little by little."
-- Charles Baudelaire (French Poet, 1821-1867)

Recently, Senior Technical Editor Dan Velasco wrote an article on how to connect to the popular open source database MySQL from WebSphere Studio Application Developer (see http://www.webspherepower.com/issues/issue200310/00001111001.html). Once you've created your application using MySQL, though, you'll want to deploy it to an application server, presumably WebSphere Application Server. To use MySQL on the application server, you will need to create a JDBC (Java Data Base Connectivity) data source if you want to take advantage of the connection pooling capabilities inherent in the WebSphere platform.

Creating a JDBC MySQL data source involves three independent steps, all accomplished with the WebSphere Application Server's Administrative Console facility. In order, these three steps are:

  • Create a MySQL JDBC provider.
  • Create the basic MySQL data source configuration.
  • Add six custom properties to the MySQL data source configuration.

We'll walk through each of these steps, one step at a time.

Open the WebSphere Application Server Administrative Console

JDBC data sources are created in the WebSphere Application Server using the built-in Administrative Console, a Struts 1.0 application that comes bundled with the product. To activate the Administrative Console, open a Web browser and enter the following URL:

https:\//<server-name>:9043/admin

Figure A illustrates the screen that will come up if all is working correctly with your application server and the Administrative Console has been enabled.

FIGURE A

Log into your Administrative Console. (click for larger image)

If you have security turned on for the Administrative Console, the screen will also contain a password field and you will have to enter a valid user name and password to authenticate to the server. If you do not have security turned on, you can enter any username that you wish. Once you authenticate to the server, you will see the home page of the Administrative Console, depicted in Figure B.

FIGURE B

Welcome home. (click for larger image)

Create the JDBC provider

The first step in creating the Data Source is to create the MySQL JDBC provider. Open up the Resources menu by clicking on the little plus sign (+) in front of the word Resources and then click on JDBC Providers. This should bring you to the screen found in Figure C.