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;
as explained in TOTD #106.
- 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.
- TOTD #112: Exposing Oracle database tables as RESTful entities using JAX-RS, GlassFish, and NetBeans
- TOTD #121: JDBC resource for MySQL and Oracle sample database in GlassFish v3
- TOTD #108: Java EE 6 web application (JSF 2.0 + JPA 2.0 + EJB 3.1) using Oracle, NetBeans, and GlassFish
- TOTD #25: Rails application with PostgreSQL database using NetBeans
- Database-enabled Hello World RoR app