In this article we see how to connect to an Oracle database from Eclipse . To do this we use a plugin called “ Toad Extension for Eclipse “, developed by the same authors of “ Toad for Oracle “, the development and monitoring environment for Oracle programmers and DBAs used as the main alternative to Oracle SQL developer.
First we need to install the plugin. We go therefore into the Eclipse marketplace, choosing the menu “Help” -> “Eclipse Marketplace ..”, and in the search box we type “Oracle”:
Among the first search results we can found the “Toad Extension for Eclipse” plugin we were looking for and we can then proceed with its installation.
Once the installation is finished, we are asked for an Eclipse restart and, at the next startup, we are shown a welcome screen that invites us to select what are the DBMS we’are supposed to work with and to use the plugin for. In addition, we are also asked to indicate for each of them the position of the relevant driver.
So, we select the “Oracle Database” and, using the “Browse” button, we choose the path where the “JDBC drivers for Oracle” jar file is available. If you don’t yet have them you can download them at the link: Oracle Database 11g Release 2 JDBC Drivers
At this point, in Eclipse we will have a new perspective available, called Toad/Java , and we can open it as usual from the menu: “Window” -> “Perspective” -> “Open Perspective” -> “Toad/Java” as shown in the following figure:
In this perspective, we can find the Connections panel in the upper-left corner. Here, using the appropriate button, we can create a new connection by choosing the right DBMS target. In our case we choose of course “Oracle Database.”
At this point we are shown the form to enter the information needed to establish the connection to the desired Oracle Database, namely:
- Port (default 1521)
- User/Schema and Password
After entering this information it is possible to make a pre-test to verify that the connection is working properly.
In case of a positive test result, we can proceed with the connection to the database by clicking “OK”. The new connection will appear then in the “Connections” panel saw earlier, while in the “Object Explorer” panel below we find all of the objects related to the Oracle database we are connected to.
In the Eclipse main panel instead it opens a “worksheet” where we can write our queries and other statements we want to perform on the database. If we try for example to execute a query, we will see the results table in a panel below.