Login | Register   
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 3

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


advertisement
Creating a MySQL DataSource
After defining your MySQL JDBC provider and creating your J2C authentication data entry, you can move on to creating your MySQL DataSource. From the left-hand panel of your administrative console (see Figure 8), choose Resources>JDBC Providers. In the subsequent JDBC providers screen, choose the MySQL JDBC Provider (which is the provider you created earlier):

From the subsequent Configuration screen, choose Data Sources under the Additional Properties section (see Figure 9). In the screen that follows, click on the New button to specify that you want to create a new Data Source.


Figure 8. Choose the MySQL JDBC provider object from the JDBC Providers section in the right column.
 
Figure 9. Look for the link to "Data Sources" in the right column, under Additional Properties in order to move to the next screen.



Next, you will be presented with the Data Source Configuration screen (see Figure 10). Specify a name for your DataSource. I called mine MySQLDataSource. Also, specify a JNDI name for your DataSource. I specified jdbc/mysqlds.

Further down in the DataSource configuration screen, specify a component-managed authentication alias of MySQLAdmin by choosing it from the drop-down list. This alias is the one you created earlier in the section on "Setting Up the J2C Authentication Data."

Click Apply for the changes to take effect. Before moving on, you need to specify some additional properties for WAS to connect to the MySQL database. Under the Additional Properties section, choose Custom Properties from the right-hand column (see Figure 11).


Figure 10. Fill out the properties fields for the configuration of your Data Source.
 
Figure 11. The Custom Properties section in the right column is your next destination. Use it to specify additional properties for connecting WAS to MySQL.

Using the New Button, create three custom properties. The data for the custom properties is shown in Table 1. The value of your server-name should be replaced to localhost if you are co-locating WAS and MySQL on a single machine. If not, it should be replaced with either the IP address or hostname of the remote MySQL machine. I am also assuming that MySQL is listening on port 3306 (the default installation port). If this is not the case, you should replace your value accordingly.

Table 1. Values for the three custom properties you need to connect WAS to MySQL.

Name Type Value
databaseName java.lang.String testdb
Port java.lang.String 3306
serverName java.lang.String <server-name>

Figure 12 shows the custom properties defined. During the definition process, you will need to save your changes to the master configuration after defining each property.


Figure 12. Each of the three custom properties has now been defined.
 
Figure 13. The message shown at the top of the screen shot lets you know that your connection was successful.

After creating your DataSource, go back to the Data Sources main window. Here, you'll find a button to "Test connection." Use the Test Connection facility to make sure WAS can talk to MySQL as expected.

You will receive a success message if your DataSource was properly configured (see Figure 13).



Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap