This guide is a quick overview of how to use MySQL with WAS.
Before we begin, we first download the MySQL JDBC connector
http://dev.mysql.com/downloads/connector/j/

Create the JDBC Provider definition for MySQL

Log in to the WebSphere 8 Administrative Console select JDBC providers from the JDBC group in the Resources section.

Choose you scope and then click New

As seen in the actual JAR you can use this path inside the expanded JAR file (use 7zip to explore JAR).

mysql-connector-java-5.1.18-bin.jar\com\mysql\jdbc\jdbc2\optional\

 

This allows me to deduce that we can Enter com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource in the Implementation class name field.

Click Next to define the location of the JAR file.

I have downloaded to [/var/apps/mysql_jdbc/mysql-connector-java-5.1.18/ mysql-connector-java-5.1.18-bin.jar]

Click Next

Click Finish and Save.

Create a JDBCdatasource

Using the MySQl provider we added we are gong to crate and test a data source

Select Data sources, then choose your scope ie Cell scope and click New

Type in an appropriate JNDI name and actual data source name.

I used MYSQL_DataSource as my name and jdbc/mysql_datasource as my jndi name.

Click Next

On the select JDBC provider page, choose the MYSQL Provider we created above.

Use the defaults…

Click Next again

Click Next to continue, then review summary and click Finish and Save.

Now we need to crate a J2C authentication alias. In the Data sources list screen, click the new Data source.

Locate the Related item section and click on JAAS – J2C Authentication data

 

Click New

Add an Alias, Usr Id and password .

 

Click Apply and on the Data sources list page we can test using the Test Connection button.

Result of successful test in SystemOut.log and message on screen

What we need to do now is add additional JDBC Data source options. We need to specify some additional properties for WAS to connect to the MySQL database.

This document contains the additional information on how to set Custom Properties required to configure a MySQL data source. Use this document in conjunction with my Original MySQL document.

Navigate to the Data Sources view by clicking on Resources | JDBC | JDBC Providers

Click to open the settings page for the appropriate Data source

Select you appropriate Data Source an click to open.

Locate the Additional properties section and click on Custom properties link

We need to add three properties to ensure our MySQL data source is used correctly.

Values for the three custom properties you need to ensure WAS knows how to connect to MySQL.

Name Type Value
databaseName java.lang.String <you database name>
Port java.lang.String 3306
serverName java.lang.String localhost

 

You need to do this for all Data Sources to ensure each Data Source has the correct Database specified.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply