Sun GlassFish Enterprise Server v3 Prelude Administration Guide

Setting Up the Database

Most applications use relational databases to store, organize, and retrieve data. Applications access relational databases through the JavaTM Database Connectivity (JDBC) API.

The following topics are addressed here:

ProcedureTo Install the Database and Database Driver

  1. Install a supported database product.

    To see the current list of database products supported by Enterprise Server, refer to the Sun GlassFish Enterprise Server v3 Prelude Release Notes.

  2. Install a supported JDBC driver for the database product.

    For a list of drivers supported by Enterprise Server, see Configuration Specifics for JDBC Drivers.

  3. Make the JAR file for the JDBC driver accessible to the domain administration server (DAS).

    See Integrating the JDBC Driver.

  4. Create the database.

    The application provider usually delivers scripts for creating and populating the database.

ProcedureTo Start the Database

Enterprise Server includes an implementation of Java DB, however, you can use any JDBC-compliant database. The database is not started automatically when you start Enterprise Server, so if you have applications that require a database, you need to start Java DB manually by using the local start-database command.

  1. Start the database by using the start-database(1) command.

    When the database server starts, or a client connects to it successfully, the following files are created at the location that is specified by the --dbhome option:

    • The derby.log file contains the database server process log along with its standard output and standard error information.

    • The database files contain your schema (for example, database tables).

Example 5–1 Starting a Database

The following example command starts Java DB on port 5001 of localhost:

asadmin start-database --dbhost=localhost --dbport=5001

Information similar to the followingt is displayed (partial output):

Database started in Network Server mode on host localhost and port 5001.
--------- Derby Network Server Information --------
Version: CSS10020/ - (538595)  Build: 538595  DRDA Product Id: CSS10020
-- listing properties --
Starting database in the background.
Log redirected to C:\prelude\v3_prelude_release\distributions\web\target\glassfi
Command start-database executed successfully.

See Also

To see the full syntax and options of the command, type asadmin start-database --help at the command line.

ProcedureTo Stop the Database

The local stop-database command enables you to stop Java DB on a specified port. A single host can have multiple database server processes running on different ports.

  1. If necessary, notify users that the database is being stopped.

  2. Stop the database by using the stop-database(1) command.

Example 5–2 Stopping a Database

The following example command stops Java DB on port 5001 of localhost:

asadmin stop-database --dbhost=localhost --dbport=5001

Information similar to the following is displayed:

onnection obtained for host: localhost, port number 5001.
Apache Derby Network Server - - (538595) shutdown at 2008-10-17 23:34:2
7.218 GMT
Command stop-database executed successfully.


For a laptop that roams between networks, you might have trouble shutting down the database. If you start Java DB and then change your IP address, you will not be able to stop Java DB unless you add a specific --dbhost argument. For example, if you run asadmin start-database --dbhost =, and then disconnect Ethernet and switch to wifi, you should run a command similar to the following to stop the database:

asadmin stop-database --dbhost localhost

See Also

To see the full syntax and options of the command, type asadmin stop-database --help at the command line.

Java DB Utility Scripts

The Java DB configuration that is available for use with Enterprise Server includes scripts that can help you use Java DB. The following scripts are available in the as-install/javadb/frameworks/NetworkServer/bin directory:


Script to start the network server


Script to stop the network server


Interactive JDBC scripting tool


Script to view all or part of the DDL for a database

sysinfo, sysinfo.bat

Script to display versioning information about the Java DB environment


Script to execute commands on the NetworkServerControl API

ProcedureTo Configure Your Environment to Run Java DB Utility Scripts

  1. Ensure that the JAVA_HOME environment variable specifies the directory where the JDK is installed.

  2. Set the DERBY_HOME environment variable to point to the as-install/javadb directory.

See Also

For more information about these utilities, see the following documentation: