This page last changed on Sep 22, 2005 by jeff.

This page will help you set up a database connection (DataSource) in Websphere 5.1, through the Websphere admin console.

Locate the Websphere admin console.

Go to the Websphere admin webapp, which will be accessible on a URL like http://yourserver:9090/admin
http://yourserver:9090/admin

Create a JDBC Provider

Click on Resources -> JDBC Providers, and create a new JDBC Provider for the database you wish to deploy to. Here we are using MySQL:

When configuring the JDBC Provider, set the Classpath field to include the JDBC driver jar.

In the Implementation Classname field, you need to enter the name of a DataSource implementation classname, not the JDBC driver classname. For instance, the MySQL JDBC driver class is 'com.mysql.jdbc.Driver',but here we need to enter 'com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource'.

How do you know what class name to enter here? 'Consult your vendor documentation' - or take a guess by looking at the contents of the JDBC driver jar:

jturner@teacup:~/mysql$ jar tvf mysql.jar | grep DataSource
1216 Thu Jun 23 00:27:38 EST 2005 com/mysql/jdbc/jdbc2/optional/MysqlConnectionPoolDataSource.class
5785 Thu Jun 23 00:27:40 EST 2005 com/mysql/jdbc/jdbc2/optional/MysqlDataSource.class
2927 Thu Jun 23 00:27:40 EST 2005 com/mysql/jdbc/jdbc2/optional/MysqlDataSourceFactory.class
jturner@teacup:~/mysql$

Create a DataSource

Now click on your newly created JDBC provider, scroll down to the bottom of the right panel, and add a DataSource (the name doesn't matter):

The important thing to get right here is the JNDI Name. This must be the same as that specified in your webapp. For JIRA, that means it has to correspond to:

<jndi-jdbc jndi-server-name="default" jndi-name="jdbc/JiraDS"/>

in WEB-INF/classes/entityengine.xml.

Configure the DataSource

Now scroll to the bottom of the Data Source right panel, and click 'Custom Properties'. Oddly enough, this is where you configure your DataSource with the username, password and database URL to use.

As for the property names, you can simply guess ('user', 'username', etc), or you can introspect the class you specified earlier as follows:

jturner@teacup:~/mysql$ export CLASSPATH=mysql.jar
jturner@teacup:~/mysql$ jar tvf mysql.jar \| grep DataSource
1216 Thu Jun 23 00:27:38 EST 2005 com/mysql/jdbc/jdbc2/optional/MysqlConnectionPoolDataSource.class
5785 Thu Jun 23 00:27:40 EST 2005 com/mysql/jdbc/jdbc2/optional/MysqlDataSource.class
2927 Thu Jun 23 00:27:40 EST 2005 com/mysql/jdbc/jdbc2/optional/MysqlDataSourceFactory.class
jturner@teacup:~/mysql$ javap com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Compiled from "MysqlDataSource.java"
public class com.mysql.jdbc.jdbc2.optional.MysqlDataSource extends com.mysql.jdbc.ConnectionProperties implements javax.sql.DataSource,javax.naming.Referenceable,java.io.Serializable{
protected static com.mysql.jdbc.Driver mysqlDriver;
protected java.io.PrintWriter logWriter;
protected java.lang.String databaseName;
protected java.lang.String encoding;
protected java.lang.String hostName;
protected java.lang.String password;
protected java.lang.String profileSql;
protected java.lang.String url;
protected java.lang.String user;
protected boolean explicitUrl;
protected int port;
public com.mysql.jdbc.jdbc2.optional.MysqlDataSource();
public java.sql.Connection getConnection()       throws java.sql.SQLException;
public java.sql.Connection getConnection(java.lang.String, java.lang.String)       throws java.sql.SQLException;
public void setDatabaseName(java.lang.String);
public java.lang.String getDatabaseName();
public void setLogWriter(java.io.PrintWriter)       throws java.sql.SQLException;
public java.io.PrintWriter getLogWriter();
public void setLoginTimeout(int)       throws java.sql.SQLException;
public int getLoginTimeout();
public void setPassword(java.lang.String);
public void setPort(int);
public int getPort();
public void setPortNumber(int);
public int getPortNumber();
public void setPropertiesViaRef(javax.naming.Reference)       throws java.sql.SQLException;
public javax.naming.Reference getReference()       throws javax.naming.NamingException;
public void setServerName(java.lang.String);
public java.lang.String getServerName();
public void setURL(java.lang.String);
public java.lang.String getURL();
public void setUrl(java.lang.String);
public java.lang.String getUrl();
public void setUser(java.lang.String);
public java.lang.String getUser();
protected java.sql.Connection getConnection(java.util.Properties)       throws java.sql.SQLException;
static {};
}

Here we can see that the DataSource class has 'setUser', 'setPassword' and 'setURL' methods, so we can infer the existence of 'user', 'password' and 'url' properties:

At this point you can test the connection (the 'Test Connection') button, and if it all works, save the changes.


ws_jdbc.png (image/png)
ws_ds_props.png (image/png)
ws_ds_new.png (image/png)
ws_ds.png (image/png)
ws_jdbc_config.png (image/png)
Document generated by Confluence on Oct 06, 2009 00:26