FreeKB - Create J2C alias in WebSphere
Create J2C alias in WebSphere

Home > Search


Before creating a J2C, you will ususally create a JDBC resource such as a data source or JMS resource such as a connection factory.

  1. In the WebSphere web console, expand Resources > JDBC or Resoruces > JMS.
  2. Select a resource.
  3. Select JAAS - J2C authentication data.
  4. Select New.
  5. Give the J2C alias a name and define the username and password. Select OK.
  6. Select Save.

 

In this example, a J2C alias for a mySQL data source is created.

 

On the WebSphere server, the J2C aliases you've created will be in the security.xml file.

Now that you've created the J2C alias, you'll want to configure a data source to use the J2C alias. Select your data source. In the Component-managed authentication alias or Container-managed authentication alias, select the J2C alias you just created and select OK. You would use Component-managed authentication alias if the application using the data source has "Application" as the res-auth policy in the Deployment Descriptor. You would use Container-managed authentication alias if the application using the data source has "Container" as the res-auth policy in the Deployment Descriptor. If the Deployment Descriptor has not specified a res-auth policy, the default is "Application", which means you would only use Container-managed authentication alias when an application has specified "Container" as the res-auth policy.

 

  1. Select Save.
  2. Restart the application server and/or deployment manager.
  3. Check the data source and select Test connection. You must have the Administrator or Operator role to be able to test conection. If the connection is successful, the following message should be displayed.

 

Likewise, when an application that is configured to use a data source to make a database connection, the application should be able to connect to the database. For example, let's say there is a Java app that contains markup to connect to a MySQL database.

@Resource(name = "jdbc/mySQL")

 

When the app resides on WebSphere, the app will know to use the MySQL data source when connecting to the database. In this example, the application is able to connect to the database.

 

Likewise, at Monitoring and Tuning > Performance Viewer > Current activity > your application server > Summary Reports > JDBC Connection Pools > your JDBC provider > your JNDI, the connection count should be 1 for the single connection to the database.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter baeb8 in the box below so that we can be sure you are a human.




Comments