Accessing Database using Eclipse/ Rational Application Developer

If your someone like me who is using Eclipse/ RAD for most of the development work and want to connect to database then you might want to consider using Database development perspective in Eclipe/RAD. The database perspective allows you to work with any database using JDBC. It is almost same in both Eclipse and RAD. I took these screen shots in Eclipse Galileo but the basics remain same in RAD.

In my case i am using Apache Derby database and i wanted to work with it. Before i do that i will have to configure the Derby driver. These are the steps that you can follow to configure and use your database


  1. In your IDE click on Windows -< Preferences and it will open preferences window. In the preferences window click on Data -< Connectivity -< Driver definitions.



  2. Click on Add and it will open New Driver Definition dialog box like this. Since i want to connect to Network version of Apache Derby 10.2, i will select it like this


  3. As you can see when we select the Derby Client JDBC Driver, it is giving an error message "Unable to locate JAR/zip in file system as specified by the driver definition: derbyclient.jar.", that is because Eclipse is not able to find the .jar file containing the database driver for Apache Derby.
  4. Switch to the Jar list tab like this, on this tab you will notice that derbyclient.jar is already added but it is not pointing to actual file on your machine so remove empty derbyclient.jar and add the derbyclient.jar on your machine like this


  5. Save your changes and it will take you back to the Driver definitions list, Since i configured only Apache Derby so far, it is listed here. If you want to connect to additional databases configure them over here.




Now once the Database driver is configured, next step is to configure Database connection follow these steps for that.

  1. Switch to Database development perspective and in the Datasource Explorer view click on New Connection Profile to get Connection Profile dialog like this


  2. On the next page configure your database connection properties such as DB Name, user id password, same properties as you will use to connect to that database using JDBC.


  3. After setting properties, click on Test Connection button to verify that your actually able to connect to database. If everything works fine click on Finish

  4. Once the connection is open you should be will get a view like this, you can use the SQL scrapbook to write one or more query and execute them against the database or you can use database explorer view to explore the database structure.



9 comments:

Lalitha said...

thanks a lot....it was really very helpful but on clicking on test connection I am getting: ping failed. could u please help me with that.

thanks.

vijay said...

can u provide me solutions to fetch data from MySQL using RAD v7.5 and Websphere portal v6.1

Anonymous said...

thanks a lot

Unknown said...

Do you have the Derby Server running?

It's quite possible that you are trying to connect to a database without the actual server running on Port 1527.


Try this if you like:

Open a command prompt->
Navigate to your Derby installation directory->
Navigate to the "bin" directory
-> Type "startNetworkServer" and press Enter

You should get a message that says something like this:

2012-08-29 10:57:16.559 GMT : Security manager installed using the Basic server security policy. 2012-08-29 10:57:16.809 GMT : Apache Derby Network Server - 10.6.2.1 - (999685) started and ready to accept connections on port 1527

Unknown said...

Do you have the Derby Server running?

It's quite possible that you are trying to connect to a database without the actual server running on Port 1527.


Try this if you like:

Open a command prompt->
Navigate to your Derby installation directory->
Navigate to the "bin" directory
-> Type "startNetworkServer" and press Enter

You should get a message that says something like this:

2012-08-29 10:57:16.559 GMT : Security manager installed using the Basic server security policy. 2012-08-29 10:57:16.809 GMT : Apache Derby Network Server - 10.6.2.1 - (999685) started and ready to accept connections on port 1527

Aamer Syed said...

thanks bro @@@

Aamer Syed said...

Im getting this error when trying to open data source explorer in eclipse for crystal reports ::
Could not connect to New Generic JDBC.
Error creating SQL Model Connection connection to New Generic JDBC. (Error: Connection failed with unspecified error.)
Connection failed with unspecified error.
Error creating JDBC Connection connection to New Generic JDBC. (Error: Connection failed with unspecified error.)
Connection failed with unspecified error.
help will b highly appreciated

Prathamesh Hule said...

Thank you so much!!!
The article was really very helpful.:)

Abhi said...

Thanks for info....
SEO Company in Bangalore