Setting up with Oracle

Now it is time for us to setup the biggest, most important, and best known player in the database world: Oracle.

Oracle's database system is considered by many to be the most feature-complete, functional, and reliable database system on the market. Different versions are suited for different needs and can range from free cut-down versions to full blown suites, with every possible feature and tweak.

Getting ready

There are many versions that can be used with NetBeans. The version we will use for this recipe is the Oracle 10g Express Edition. It is free to develop for and fairly easy to install.

It is necessary to have Oracle 10g Express Edition installed on the system and fully configured. In this recipe, we will demonstrate only how to make Oracle accessible from within NetBeans.

Here's where to find Oracle 10g Express Edition:

http://www.oracle.com/technology/software/products/database/xe/index.html

For this recipe to work, it is also necessary to download the JDBC driver, named ojdbc14.jar, so it can interface between NetBeans and the Database.

Visit the page below to download the driver:

http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html

Once the Database is installed and running, and the JDBC driver downloaded, we can proceed to configure NetBeans.

How to do it...

Navigate to the Services window:

Adding a new driver:

  1. Right-click on Databases subsection and select New Connection....
  2. When New Database Connection window opens, click on the Driver Name drop-down and select New Driver....
    How to do it...
  3. When selecting New Driver... under the drop-down, the New JDBC Driver window will pop-up.
  4. Then click on Add... and navigate to the location of the driver JAR file.
  5. When selecting the driver, the Driver Class will be changed to oracle.jdbc.OracleDriver and Oracle Thin under Name.
  6. Click OK.
How to do it...

The control then returns to the New Database Connection window.

The next step is to enter basic database information.

Note that the following information is not set in stone and you might have changed it when installing and configuring the database. So if all the defaults were used, it is possible that all the information is the same as presented here:

  • Host: localhost
  • Port: 1521
  • Service ID: XE
  • User: system
  • password: the password that was entered during installation
  • Click on Show JDBC URL.

Now that everything looks more or less like the following, it is important to notice the pattern of the JDBC URL:

How to do it...

Click OK and the control will be passed to the Advanced tab, select system as the Schema (or one of your choice), and click OK.

How it works...

This is the first database in this Cookbook that is required to find a JAR file to connect properly.

This is because NetBeans is not providing the JAR file from its package by default. NetBeans provides drivers for MySQL and together with GlassFish Server, also Java DB.

As shown in the registration procedure, after entering the required information, it is important to notice the format of the URL, which needs to be:

jdbc:oracle:thin:@localhost:1521:XE

XE comes from Express Edition and this is the desired format.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.208.203