Thursday, 6 February 2014

Creating JDBC Provider and DataSource in WebSphere Portal

Ref URL : http://www.websphereusergroup.org/steverobinson/blog/2012/07/23/using_mysql_with_websphere_application_server
 http://www.websphereusergroup.org/go/thread/view/108057/30020763/Error_trying_to_connect_Mysql_Database

 Problem: If server couldn't reach database server. To solve the problem, I got into "custom properties" and set the "url" property with jdbc connection string. Now everything works fine and operative

For MYSQL
---------

** required jar file 'mysql-connector-java-5.1.6.jar'

Process to configure JDBC Provider
----------------------------------
1. Goto Admin console, Resources -> JDBC -> JDBC Provider -> New
2. Select the  Database type  you would like to use from the dropdown list(here i used MYSql so i selected user-defined)
3. Provide Implementation class name for MYSql, i.e. 'com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource'
4. And specify a name and description for jdbc provider.
5. And specify 'mysql-connector-java-5.1.6.jar' file path, i.e. D:/jars/mysql-connector-java-5.1.6.jar
6. And provide Native library path(.dll file path) if requried

Now your JDBC Provider created.

Process to configure Datasource
-------------------------------
1. Goto Admin console, Resources -> Data sources -> New
2. Provide custom Datasourcename and JNDIname
3. Select an existing JDBC Provider just we created.
4. Specify 'Data store helper class name' value with this 'com.ibm.websphere.rsadapter.ConnectJDBCDataStoreHelper'
5. At 'Setup security aliases' dont select any thing just click next and finish.

Now your Data source created, now you have to provide authentication and database details.

6. Now click on Datasource just now we created
7. Here you can see 'JAAS - J2C authentication data' link click on that and select New
8. Now you provide
-> Alias, any name to refer for security
-> User ID, database userid i.e. root for mysql
-> Password, database password, and save.
9. Now here 'JAAS - J2C authentication data' has created which is used to connect to database
10. Now click on Datasource and goto 'Security settings' and configure following properties,
-> Component-managed authentication alias, from drop down select just now created alias name
-> Mapping-configuration alias, from drop down select 'DefaultPrincipalMapping'
-> Container-managed authentication alias, from drop down select just now created alias name, and save.
11. Now click on Datasource and click on 'Custom properties' link
12. Here we need to provide below three properties so that WAS can connect to MySQL
-> serverName (with ip address)
-> port (3306)
-> databaseName  (sumandb)
13. Now restart the portal server to apply changes.








No comments:

Post a Comment