TOTD #107: Connect to Oracle database using NetBeans
By arungupta on Sep 30, 2009
TOTD #106 explained how to install Oracle database 10g R2 on Mac OS X. This Tip Of The Day will explain how to connect Oracle database with NetBeans to leverage all the goodness provided by NetBeans for Java EE application development, Rails, and others.
- Download Oracle JDBC Drivers, specifically ojdbc14.jar. (ojdbc6.jar is recommended to be used with GlassFish v3).
- Using NetBeans 6.8 M1, in Services tab, right-click on "Databases" and select "New Connection..." as shown:
- Expand "Name:" and select "New Driver...":
- Click on "Add..." and choose the recently downloaded JDBC driver JAR file as shown below:
and click on "OK".
Enter the database values as shown below:
The password is "hr" for the sample HR database. Clicking on "Show JDBC URL" also shows the complete JDBC URL. Click on "OK".
You may have to unlock the "hr" user by giving the command:
ALTER USER HR IDENTIFIED BY hr ACCOUNT UNLOCK;
- Select the "HR" schema as shown below:
and click on "OK". The complete list of schemas is now shown in the "Databases" node as shown below:
- Expand the "HR" node and the complete list of tables is visible now:
Expanding each table shows you the complete definition as shown:
- Right-click on "COUNTRIES" table and select "View Data..."
and the result is shown as:
Additionally, you can execute any SQL command by selecting "Execute Command...":
A complete archive of all the TOTDs is available here.
Subsequent blogs will show how to write a Java EE application to access the Oracle database.