start-database

Starts a standalone H2 database in server mode.

Synopsis

asadmin [asadmin-options] start-database [--help]
[--jvmoptions jvm-options]
[--dbhost host] [--dbport port-no]
[--dbhome db-file-path]

Description

The start-database subcommand starts the H2 database server that is available for use with Payara Server. Use this subcommand only for working with applications deployed to the server.

When you start the H2 server by using the start-database subcommand, the database server is started in Network Server mode. Clients connecting to it must use the corresponding H2 JDBC client driver. For details on how to connect to the database, refer to the official H2 documentation.

When the database server starts, or a client connects to it successfully, the following files are created:

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

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

These files are created at the location that is specified by the --dbhome option. To create the database files at a particular location, you must set the --dbhome option. If the --dbhome option is not specified, the start-database subcommand determines where to create these files as follows:

  • If the current working directory contains a file that is named h2.log, the start-database subcommand creates the files in the current working directory.

  • Otherwise, the start-database subcommand creates the files in the as-install/databases directory.

The start-database subcommand starts the database process, even if it cannot write to the log file.

This subcommand is supported in local mode only.

Options

asadmin-options

Options for the asadmin utility. For information about these options, see the asadmin help page.

--help
-?

Displays the help text for the subcommand.

--jvmoptions

A space-separated list of command-line options that are passed to the Java application launcher when the database is started. By default, no options are passed.

The format of an option depends on whether the option has a name and a value or only a name:

  • If the option has a name and a value, the format is option-name=value.

  • If the option has only a name, the format is option-name. For example, -Xmx512m.

--dbhost

The host name or IP address of the H2 database server process. The default is the IP address 0.0.0.0, which denotes all network interfaces on the host where you run the start-database subcommand.

--dbport

The port number where the H2 database server listens for client connections. This port must be available for the listen socket, otherwise the database server will not start.

--dbhome

The absolute path to the directory where the database files and the h2.log file are created. If the --dbhome option is not specified, the start-database subcommand determines where to create these files as follows:

  • If the current working directory contains a file that is named h2.log, the start-database subcommand creates the files in the current working directory.

  • Otherwise, the start-database subcommand creates the files in the as-install`/databases` directory.
    To create the database files at a particular location, you must set the --dbhome option.

Examples

Example 1 Starting Java DB

This example starts H2 on the host host1 and port 5001.

asadmin> start-database --dbhost host1 --dbport 5001 --terse=true

Starting database in Network Server mode on host 0.0.0.0 and port 9092.
tcp://10.228.1.149:9092
Starting database in the background.
Log redirected to /opt/databases/h2.log.

Example 2 Starting H2 with Options for the Java Application Launcher

This example starts H2 with the options for setting the minimum heap memory size to 128 megabytes and the maximum heap memory size to 512 megabytes.

asadmin> start-database --jvmoptions="-Xms128m -Xmx512m" --terse=true

Starting database in Network Server mode on host 0.0.0.0 and port 9092.
tcp://10.228.1.149:9092
Starting database in the background.
Log redirected to /opt/payara/glassfish/databases/h2.log.

Exit Status

The exit status applies to errors in executing the asadmin utility.For information on database errors, see the h2.log file. This file is located in the directory you specify by using the --dbhome option when you run the start-database subcommand. If you did not specify --dbhome, the value of H2_INSTALL defaults to as-install/h2.

0

subcommand executed successfully

1

error in executing the subcommand

See Also