Sun Java System Application Server Platform Edition 8.2 Release Notes

Using the Bundled Derby Database

This section provides instructions for using the Derby database implementation bundled with Application Server 8.2.

Starting and Stopping the Derby Database

Sun Java System Application Server 8.2 introduces two new asadmin commands for starting and stopping the Derby Network Server.

Derby Utility Scripts

The Derby configuration that ships with Application Server 8.2 also includes several useful scripts which can help you use Derby. The following scripts are available for use in the <appserver_install_dir>/derby/frameworks/NetworkServer/bin directory:

ProcedureTo Configure Your Environment to Run the Derby Utility Scripts

  1. Set the DERBY_INSTALL environment variable to point to the <appserver_install_dir>/derby directory.

  2. Unset your CLASSPATH environment variable.

  3. You can also optionally set the following properties:

    1. DERBY_SERVER_HOST to the host on which the network server will listen.

      Can also be set to to enable all listeners.

    2. DERBY_SERVER_PORT to the port number on which the network server will listen.

See Also

For more information about these utilities, see the Derby Tools and Admin guides.

Exporting Tables from Pointbase to Derby

This example shows how to capture the DDL for a table in Pointbase and create the same table in Derby using Netbeans 5.0. Another option for doing this is by using the commander tool and the unload database command:

Do you wish to create a new Database. (Yes (Y) or No (N))? [default: N]: 
Enter product to connect with: (Embedded (E) or Server (S))? [default: E]: e
Enter driver to use? [default: [com.pointbase.jdbc.jdbcUniversalDriver]: 
Enter database URL? [default: [jdbc:pointbase:embedded:sample]: 
Enter Username? [default: PBPUBLIC]: 
Enter Password? [default: PBPUBLIC]: 

PointBase Commander 5.2 ECF build 294 size restricted version EMBEDDED

Interactive SQL command language. SunOS/5.9

(C) Copyright 2004 DataMirror Mobile Solutions, Inc. All rights reserved.

Licensed to: Sun_customer_demo_use
For commercial version contact PointBase at:
PHONE: 1-877-238-8798 (US & CANADA)
       1-408-961-1100 (International)

SQL>unload database sampledb.sql;
SQL> unload database sampledb.sql;
SQL> 13 Row(s) Unloaded. (PBPUBLIC.CUSTOMER_TBL)
SQL> 9 Row(s) Unloaded. (PBPUBLIC.OFFICE_TBL)
SQL> 15 Row(s) Unloaded. (PBPUBLIC.ORDER_TBL)
SQL> 30 Row(s) Unloaded. (PBPUBLIC.PRODUCT_TBL)
SQL> 10 Row(s) Unloaded. (PBPUBLIC.SALES_REP_TBL)
SQL> 12 Table(s) Unloaded.
SQL> quit;

The results from executing the unload database command is written in the above example to the file sampledb.sql. The sampledb.sql file contains all of the DDL required to create the necessary tables and indexes. It also contains the DML to insert the data back into the database. The commander command RUN is intended to be used import the data into another Pointbase database using the script that was generated. Here is an example of what the INSERT statements and associated data look like in the generated file:

VALUES( ?, ?, ?, ?, ? );
'ISLAND              ','en_US','Island Adventures','Experience an island /
paradise in a way fit for your needs.','Island_Adventures.gif'
'JUNGLE              ','en_US','Jungle Adventures','Experience a jungle /
paradise in a way fit for your needs.','Jungle_Adventures.gif'
'MOUNTAIN            ','en_US','Mountain Adventures','Experience an /
elevated paradise with a view.','Mountain_Adventures.gif'
'ORBITAL             ','en_US','Orbital Adventures','Experience a vacuum /
paradise with a beautiful view and where no one can hear you scream.', /
'WESTERN             ','en_US','Western Adventures','Enjoy the Wild West. /
'SOUTH_POLE          ','en_US','South Pole Adventures','Experience a /
frozen paradise in a way fit for your needs.','SouthPole_Adventures.gif'

You could easily edit the file generated from the commander unload database command so that it only consisted of the DDL (for example, it would not be hard to write a program which would process the insert statements). As a simple test, we use the unload database command against the Pointbase sample database, and then edit the generated script, making the following changes:

Next, a simple Ant script is used to execute the DDL using the sql target. Finally, the same experiment is repeated for the sun-appserv-samples database requiring the following additional changes to the generated SQL file:

Converting Pointbase Java procedures to work with Derby requires some changes to the Java code as well as to the CREATE PROCEDURE statements. Information on creating Derby Java procedures can be found in the Derby Reference manual. Support for the Boolean datatype should be in the next release of Derby.