3

How to add database to eclipse

[Social9_Share type="horizontal"]

How to add database to eclipse?

While working in java projects using databases, there are scenarios where you want go back and forth between eclipse and SQL command line. Instead of this, you can add the database(connection profile) to eclipse to view your tables, execute sql queries and so on. Lets us see how to do this in eclipse.
Open eclipse.
Go to Window -> Show View -> other

db1

select Data Management-> Data Source Explorer

db2


A new window opens.
To create a new connection profile, select Database Connection, right click and select new.

db3


A new window opens. Select the database with which you want to establish a connection.
I have selected oracle.

db4


click next. select new Driver Definition


db5


A new window opens. Select the appropriate driver to use. I am using oracle 10g. So I have selected oracle thin driver for 10g. There is also an error mark on the top saying unable to locate JAR/zip.
To add the jar file click JARList tab

db6


select odbc14.jar(This is the driver for Oracle database).You need to specify the location of this jar file.To locate the jar click Edit JAR/Zip


db7


A new window opens. select ojdbc14 from the location where oracle is installed.
( C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib)
. Click open


db8
Click ok and come back to the previous window.
In this, you need to set SID, Host, Port number User name, password. My SID is xe. The server resides in the same machine so the host is localhost.The port number for oracle is 1521. you can enter your username and password

db9


Click Test Connection button to check your connection. you will get a ping succeeded message.
If you get a ping failed message. go back to your previous window by using Edit Driver definition and check the parameters once again. Also check for your SID, username, password.


db10


If everything is perfect, click Finish. Now you can see your schema and the tables directly from eclipse.


db11



Once done, the next step is to query the database. To do this , we need a SQL command Line.Learn how to open SQL scrap book in eclipse and execute the queries.Till then
Happy Learning.

Comments(3)

  1. Reply
    chandu says

    nice work

  2. Reply
    Sanju says

    Thanks. I was searching for how to add database to eclipse , for working in my project. You saved me

Post a comment