Connecting To Oracle from Eclipse

The environment variables and the instructions you have seen in the first tutorial on JDBC are applicable only when you run your java program from the Unix command line. If you use Eclipse, things are different. Here is a short note of how to set Eclipse to work on Unix or from your home machine.

a. Using Eclipse on a ugrad Unix  Machine

Let's assume you have created an Eclipse  project called MVS  and you want to connect to Oracle. You need to tell Eclipse where to find the jdbc driver file for Oracle. To do that you should do the following:

Now you can close the properties window and go back to your project. You should be able to connect to Oracle.

 

b. Using Eclipse on your Home  Machine

To connect to Oracle you have to have the Oracle jdbc driver stored somewhere on your machine. Create a folder where you want to store this driver (i..e. if you have a cs304 folder create a "OracleDrivers" subfolder).  Using an ftp program, download the zip file with the oracle drivers either from

        /home/o/oracle/jdbc/lib/classes12.zip

or from

    ~cs304/oracledrivers/classes12.zip

and store it in the folder you created.

Start Eclipse and open your project that needs to connect to Oracle. You need to add  the jdbc driver file for Oracle to that project. To do that you should do the following:

 

c. Running the Sample Programs

In the Sample Programs of the  JDBC/Oracle Tutorial 1 there are links to two sample programs. One of them uses GUI and the other uses a funny library (hb15.zip)  that allows you to produce formatted output on the standard Java output stream. To run the programs from Eclipse, you have to set the Oracle driver as was indicated above.  To run the program that used the hb15.zip file, you must also include this file in the project as an external library, in the same way we described above.