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
Duration Time: 30 Minutes
Don't have MyEclipse? Download Now
- Start the WebSphere server from MyEclipse.
- Right-click the server in the Servers view, and select Open Admin Console. A browser opens to the Administrative Console login page.
- 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.
2. Set Up the Data Source in WebSphere
- In the menu at left, expand Resources>JDBC and select Data sources.
- 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.
- 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).
- 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
- 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.
- 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.
- 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 MyEclipse Database, and click DB Browser.
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.
- Type myeclipse in the Database Name field in the WebSphere wizard, and click Next.
- Click Next to skip security aliases for now. WebSphere displays a summary of the new data source. Click Finish.
4. Specify Security Aliases
Before saving the changes, the security aliases must be addressed.
- Click the MyEclipse Derby Data Source to open the configuration.
- Click the JAAS – J2C authentication data link under Related Items.
- Click New, enter an alias, user ID, and password, and click Apply.
- Click the Save link to commit these changes to the master configuration and have them go live on the server.
- Click the MyEclipse Derby Data Source link to return to the data source configuration.
- 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.
- Click the Save link to commit the changes.
After the data source information is committed to the server, you need to test the data source.
- 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.
- In the Administrative Console, select the checkbox beside the data source you created, and click the Test Connection button.
If the connection is successful, a confirmation appears at the top of the Administrative Console.
If the connection failed, go back to MyEclipse and be sure the MyEclipse Derby Server is running.
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.