facebook

Creating a Data Source in WebSphere

This tutorial walks you through setting up a data source in WebSphere. While focusing on setting up a data source that connects back to the MyEclipse Derby server in MyEclipse, the process is identical to set up other data source to other DBMS (like Oracle, DB2, MS SQL Server, etc.). In this tutorial, you will learn to:

  • Set up a data source using the WebSphere Admin Console
  • Test the data source

1. Access the WebSphere Admin Console

  1. Start the WebSphere server from MyEclipse.
  2. Right-click the server in the Servers view, and select Open Admin Console. A browser opens to the Administrative Console login page.

    Opening the Administrative Console from the Servers view
  3. Click the Log In button to enter the Administrative Console. Unless you set up a special account login for WebSphere you do not need a user ID.

    Administrative Console login

2. Set Up the Data Source in WebSphere

  1. In the menu at left, expand Resources>JDBC and select Data sources.
  2. Select an appropriate scope in which the new data source should exist. The scope is a specification of how “visible” you want the data source to be – visible just to a single server, to an entire node, etc.

    Specifying the data source scope
  3. Click New to add a new data source to the selected scope. Enter a name for the data source (for display purposes in the Administrative console) and a JNDI name that the data source will be bound to (use to look up the source inside your projects, for example, in an EJB 3 project). 

    Entering data source adn JNDI names
  4. Click Next. You have finished creating your data source, but your data source doesn’t expose any useful connection as a resource. The wizard now walks you through setting up a JDBC provider that is exposed by this data source.

    Note:
    You can set up a JDBC provider and then set up a data source mapped to the JDBC provider as separate steps. In this tutorial, you set up both in a single wizard.

3. Continue the Wizard: Set Up the JDBC Provider

  1. Select the JDBC provider you want to use for accessing the resource. In this case, you are going to set up a new Derby connection to the MyEclipse Derby server, so select Create new JDBC provider, and click Next.


    Creating a new JDBC provider
  2. Select the following: 

    Database type: Derby, because you are using the MyEclipse Derby server

    Provider type: Derby Network Server Using Derby Client, because you don’t want to use the embedded driver; you want to connect remotely as a client to the MyEclipse Derby server.

    Implementation type: Connection pool data source, because you want WebSphere to manage a pool of connections for this JDBC source to improve performance.

    The remaining Name and Description are filled in for you. Click Next.

    Entering JDBC provider information
  3. Enter the name of the Derby database to which you want to connect. In this case, you can find this information by viewing the default Derby connection preconfigured in MyEclipse. When you edit the connection, you see the string used, which includes the DB name at the end. Do the following to find the database name.

    In MyEclipse, open the DB Browser by selecting Window>Show View>Other from the menu. On the Show View window, expand Database, and click DB Browser.
    wsdataview
    Opening the DB Browser view

    Right-click the MyEclipse Derby database, and select Edit from the menu. The DB name is myeclipse, appended to the end of the connection URL.

    Identifying the DB name
  4. Type myeclipse in the Database Name field in the WebSphere wizard, and click Next.

    Entering the DB name
  5. Click Next to skip security aliases for now. WebSphere displays a summary of the new data source. Click Finish.

    Data source summary

4. Specify Security Aliases

Before saving the changes, the security aliases must be addressed.

  1. Click the MyEclipse Derby Data Source to open the configuration.
  2. Click the JAAS – J2C authentication data link under Related Items.

    Setting authentication data
  3. Click New, enter an alias, user ID, and password, and click Apply.
  4. Click the Save link to commit these changes to the master configuration and have them go live on the server.

    Saving the user identity and password
  5. Click the MyEclipse Derby Data Source link to return to the data source configuration.
  6. Scroll to the Security Settings section, and select the user identity you just created from the Component-managed Authentication Alias drop-down, and click OK.

    Selecting the new identity
  7. Click the Save link to commit the changes.

    Saving changes


5. Test the Data Source

After the data source information is committed to the server, you need to test the data source.

  1. In MyEclipse, right-click the MyEclipse Derby Server in the Servers view, and select Run Server. If the server is not running it will deny the incoming connection from WebSphere.
  2. In the Administrative Console, select the checkbox beside the data source you created, and click the Test Connection button.

    Testing the data source

If the connection is successful, a confirmation appears at the top of the Administrative Console.


Connection confirmation

If the connection failed, go back to MyEclipse and be sure the MyEclipse Derby Server is running.


Running Derby server

If it is running, edit your data source connection properties to ensure you entered the database name correctly as well as the other connection information. It’s also possible that if you changed the MyEclipse Derby Server instance to run on another port besides the default 1527, the data source will not be able to connect without customizing its connection settings.