Websphere and MySQL datasource

This is about how to create a MySQL datasource in Websphere Test Environment via WSAD (Websphere Studio Application Developer).

Open the server configuration and select the data source tab. Select then the following parameters

  • jdbc typeDatabase type: User-defined
  • JDBC provider type: User-defined JDBC Provider

Then hit next and in the next screen input the following parameters

jdbc settings

  • Name: MySQL
  • Description: blablabla
  • Implementation class name: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
  • class path: remove the existing one and use add external jar pointing to the right MySQL jdbc jar file (mysql-connector-java-5.0.5-bin.jar in my case).

After confirming the JDBC provider, select it from the list and select add next the data source box (just below). Use the Version 5.0 data source, and use next to proceed. Input the following data

Data source settings

  • Name: <name of the jdbc>
  • JNDI Name: jdbc/<name of the jdbc>
  • Data source helper class name: com.ibm.websphere.rsadapter.ConnectJDBCDataStoreHelper

Notice that the helper class is very important. Ensure to use the one specified or things wont works fine.

Now It’s time to input the connection parameters. In the next box (resource properties), after selecting the just created data source, click add until input all those properties:

sample property

  • databaseName: <yourdatabase>?autoReconnect=true (java.lang.String)
  • factory: com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
  • password: <the password>
  • port: 3306 (or your port if installation is customized)
  • serverName: <your server name>
  • user: <the user for connection>

After this, remember to refer to the data source in web.xml and restart the server.


9 thoughts on “Websphere and MySQL datasource

  1. yep following thing must add manually no?
    * databaseName: ?autoReconnect=true (java.lang.String)
    * factory: com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
    * password:
    * port: 3306 (or your port if installation is customized)
    * serverName:
    * user:
    anyway thanx machan..

    • WAS is quite different from the TE. I don’t exactly know how to do it as I’m not a MDW man. However I think that through the admin console of the WAS you could find something like the steps described above for the TE.

  2. Subhash Koganti says:

    Thanks a lot.

    This helped me. I was struggling to connect to MySQl from WAS 7.0 .
    It worked only after I entered the helper class that you mentioned above . In addition to that, I also configured the custom properties with the portnumber and the database name which made the connection successful.

    Subhash Koganti, MBA.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s