Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Connect MySQL to WebSphere Application Server Using a DataSource : Page 2

Making WebSphere Application Server cooperate with MySQL isn't hard. Follow along to create a DataSource that marries WAS and MySQL.


advertisement
Configuring a MySQL JDBC Provider
To configure a MySQL DataSource, you first have to define a MySQL JDBC Provider. Open the application server administrative console and from the left-hand panel, choose Resources>JDBC Providers (see Figure 1).


Figure 1. Choose the JDBC providers option under Resources to begin creating a new JDBC provider.
 
Figure 2. Choose New to specify a new JDBC provider.

From the subsequent JDBC providers screen, choose New to specify a new JDBC provider (see Figure 2).



In the next screen (see Figure 3), for "Step 1: Select the database type," specify a database type of "User-defined." For "Step 2: Select the provider type," specify a provider type of "User-defined JDBC Provider." For "Step 3: Select the implementation type," specify "User-Defined" and click Next.


Figure 3. Set the properties for the new JDBC provider as shown.
 
Figure 4. Set the name, class path, and implementation class names for the JDBC Provider.

In the next General Properties screen (see Figure 4), specify a name of MySQL JDBC Provider. Specify a class path of: C:\mysql-connector-java-3.1.12\mysql-connector-java-3.1.12-bin.jar. Note that this path should change to reflect the location of your mysql-connector-java-3.1.12-bin.jar JAR file. For your implementation class name, specify com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource. When you have specified the name, class path, and implementation class name as shown in Figure 4, click Apply. You will be prompted to save your changes to the master configuration, which you should do before moving on.

Setting Up the J2C Authentication Data
Before you can move on to creating your DataSource, you need to define some Java 2 Connection (J2C) Authentication authentication data. In short, you'll be telling WAS what user ID and password to use when connecting to MySQL. From the left-hand pane of the administrative console (see Figure 5), choose Security>Global Security.


Figure 5. Get started on your authentication definition by selecting Global security from the WAS security menu.
 
Figure 6. The Authentication section in the right column is where you can select your J2C data option.

In the Configuration screen, under the Authentication section in the right column, expand the JAAS Configuration option, and choose the J2C Authentication data option (see Figure 6).

In the J2C dialog, click the New button to create a new authentication data entry.

In the subsequent screen, you can define the data associated to your new authentication data entry. Specify an alias name for your MySQL proxy user. I specified the name MySQLAdmin. Also, specify the user ID that will connect to MySQL on WAS's behalf. This should be an authorized user which you or your MySQL administrator has authorized for accessing MySQL. In my case, I am just using the root user. Specify the user's password in the Password section (see Figure 7). After specifying an alias, user ID and password, click Apply.

Figure 7. Now that you've created an authentication data entry, populate the properties fields, according to your setup and click Apply.

You will be asked again to save your changes to the master configuration. Go ahead and do this before proceeding. After saving your changes, you should see a new entry in the Global security section corresponding to the alias you just designated to connect to MySQL on WAS's behalf.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap