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.
Window -> Show View -> other
Data Management-> Data Source Explorer
A new window opens.
To create a new connection profile, select
Database Connection, right click and select
A new window opens. Select the database with which you want to establish a connection.
I have selected
new Driver Definition
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
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
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
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
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.
If everything is perfect, click
Finish. Now you can see your schema and the tables directly from eclipse.
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