|
||
Table of Contents |
||
1. IntroductionThis document will walk you through setting up a data source in WebSphere. While this tutoral focuses on setting up a data source that connects back to the MyEclipse Derby embedded Derby instance in MyEclipse, the process is identical to setup any other data source to any other DBMS (like Oracle, DB2, MS SQL Server, etc.). |
||
2. System Requirements
This tutorial was created with MyEclipse Blue Edition 6.1 and
WebSphere 6.1. If you are using another version of MyEclipse
Blue Edition (possibly newer), most of these screens and
instructions should still be very similar.
If you are using a newer version of MyEclipse and notice portions
of this tutorial looking different than the screens you are
seeing, please
let us know and we will make sure to
resolve any inconsistencies.
|
||
3. Creating a Data SourceThe first step to creating a data source in WebSphere is to make sure the server is running and then login to the administrative console. A quick and easy way to do this from MyEclipse Blue is to right-click on the server in the Servers view, and select Open Admin Console:
This will automatically open a browser and take you to the admin console login page. By default, unless you have setup a special account for WebSphere, you can simply click the Log in button to enter the admin console with no further credentials:
Once you are in the admin console, you will want to navigate down
to the
Resources > JDBC > Data sources preference
node, once there you will want to make sure to select an
appropriate scope for the new data source to exist in:
NOTE: Your scope is simply a specification of how "visible" you want this data source to be. Just to a single server, to an entire node, etc. Once you have selected the scope of the data source, click the New button to add a new data source to that scope.
You will then be prompted to name the data source (for display
purposes in the admin console) as well as provide a JNDI name
that the data source will be bound to (and what you will use to
look it back up inside your projects to use it, for example, in
an EJB 3 project):
Click Next when done. You are actually done (that's it!) creating your data source, but the problem is that your data source doesn't expose any useful connection as a resource. The wizard will now walk you through that portion of setting up a JDBC provider that is exposed by this data source.
NOTE:
You can actually setup a JDBC provider and then a data
source mapped to it as separate steps. We are setting up both in
a single wizard in this tutorial.
Now WebSphere is going to prompt you for information about the
JDBC provider you want to associate with this data source. Frist
you need to select the JDBC provider to use to access the
resource. In our case we are going to setup a new Derby
connection back to the MyEclipse Derby Server, so we select
Create new JDBC provider:
After hitting Next, WebSphere asks for the additional details about this JDBC provider, we select:
The remaining
Name and
Description are filled in for us, so we can
click
Next:
Now WebSphere wants to know the exact name of the database in Derby that we will be connecting to. In our case we can find this information out by editing the default Derby connection that comes preconfigured in MyEclipse, when we do that we see the connection string used, which includes the DB name at the end:
So we see the DB name is
myeclipse, so we enter that in the WebSphere
wizard and click
Next:
WebSphere now shows us a summary of the new data source we setup,
we can review it and when done click
Finish.
As with all changes to WebSphere, you are given a chance of a review of the changes before publishing them to the master configuration file for the server and activating the changes.
We are comfortable with our changes, so we need to click
Save to commit these changes to the master
configuration and have them go live inside of our server:
After those changes have been published, we need to test our data source to make sure it's working. NOTE: At this point you need to make sure that the MyEclipse Derby Server is running inside of MyEclipse, otherwise it will deny the incoming connection from WebSphere.
To test the connection we check our new
MyEclipse Derby Data Source (or whatever you
named it) and click the
Test connection button:
If the connection is successful, at the top of the admin console
you will see a message similar to the one below saying so:
If for any reason the connection failed, you will first want to flip back to MyEclipse and make sure that the MyEclipse Derby Server is running:
If it is running, you will want to edit your data source
connection properties and make sure you got the database name
correct as well as other connection information. It's also
possible if you changed the MyEclipse Derby Server instance to
run on another port besides the default 1527 that the data source
will not be able to connect without customization to it's
connection settings.
|
||
4. Conclusion
While the contents of this tutorial discuss setting up a data
source in WebSphere that points to the MyEclipse Derby Server,
the process is very similar for setting up any other data source
to another data provider like Oracle, DB2 or MS SQL Server.
|
||
5. ResourcesIn this section we want to provide you with additional links to resources that supplement the topics covered in this tutorial. While this is not an exhaustive list, we do make an effort to point to the more popular links that should provide you with diverse, high-quality information. |
||
6. FeedbackWe would like to hear from you! If you liked this tutorial, has some suggestions or even some corrections for us please let us know. We track all user feedback about our learning material in our Documentation Forum. Please be sure to let us know which piece of MyEclipse material you are commenting on so we can quickly pinpoint any issues that arise. |