Setting up with Apache Derby/Java DB

Apache Derby is an Apache Foundation project that distributes an open-source RDBMS, with a staggering small footprint of only 2.6 MB, implemented in Java and is fully compatible with JDBC and SQL standards.

Java DB is Apache Derby, but packaged and distributed by Sun Microsystems/Oracle Corporation. By downloading the GlassFish Server or the JDK 6, a copy of Java DB is already included in the installation file.

Note

If you feel like learning more about Apache Derby and Java DB, visit the following links:

For Java DB, visit http://www.oracle.com/technetwork/java/javadb/overview/index.html.

For downloading JavaDB, visit http://download.oracle.com/docs/cd/E17413_01/javadb/index.html.

And for Apache Derby, go to http://db.apache.org/derby/.

Getting ready

If your version of NetBeans included GlassFish Server, Java DB is already registered.

However, if this is not the case, and the NetBeans Java SE installation package was chosen, then setup and registration of Java DB needs to be done manually.

Navigate to http://www.oracle.com/technetwork/java/javadb/downloads/index.html and download Java DB to the platform of your choice.

How to do it...

To register Java DB with NetBeans:

  1. Right-click on Java DB node inside the Databases subsection of Services window.
  2. In the Java DB Properties window, enter the installation folder of Java DB.
  3. Database Location is where the Java DB settings will be placed:
    How to do it...
  4. Click OK.

How it works...

When clicking OK under the Java DB properties window, the Java DB node will have Sample as the child, it is the Sample database that already exists in Java DB. A database connection, with Java DB values, is appended to the end of the Databases subsection.

There's more...

Viewing data using the SQL editor.

Viewing data

With Java DB registered and connected, it is possible with a few mouse clicks, to see the data in a Database from within the IDE:

  1. Expand the Sample connection until Tables is shown.
  2. Then right-click on a table, for example CUSTOMER, and select View Data....

The built-in SQL editor will be shown with the query:

select * from APP.CUSTOMER

And a grid with the present data is available.

Below is a screenshot of NetBeans with View Data... submenu, built-in SQL editor, and data grid:

Viewing data
..................Content has been hidden....................

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