Server

This tool can be used to start various database servers (listeners).

Methods
static Server createFtpServer(String[] args)
Create a new ftp server, but does not start it yet.
static Server createPgServer(String[] args)
Create a new PG server, but does not start it yet.
static Server createTcpServer(String[] args)
Create a new TCP server, but does not start it yet.
static Server createWebServer(String[] args)
Create a new web server, but does not start it yet.
Service getService()
Get the service attached to this server.
String getURL()
Gets the URL of this server.
boolean isRunning(boolean traceError)
Checks if the server is running.
static void main(String[] args)
The command line interface for this tool.
static void shutdownTcpServer(String url, String password, boolean force)
Shutdown a TCP server.
Server start()
Tries to start the server.
static void startWebServer(Connection conn)
Start a web server and a browser that uses the given connection.
void stop()
Stops the server.

static Server createFtpServer(String[] args) throws SQLException

Create a new ftp server, but does not start it yet. Example:
 Server server = Server.createFtpServer(
     new String[] { "-trace" }).start();


Parameters:
args -
Returns:
the server

static Server createPgServer(String[] args) throws SQLException

Create a new PG server, but does not start it yet. Example:
 Server server = 
     Server.createPgServer(new String[]{
         "-pgAllowOthers"}).start();


Parameters:
args -
Returns:
the server

static Server createTcpServer(String[] args) throws SQLException

Create a new TCP server, but does not start it yet. Example:
 Server server = Server.createTcpServer(
     new String[] { "-tcpAllowOthers" }).start();


Parameters:
args -
Returns:
the server

static Server createWebServer(String[] args) throws SQLException

Create a new web server, but does not start it yet. Example:
 Server server = Server.createWebServer(
     new String[] { "-trace" }).start();


Parameters:
args -
Returns:
the server

Service getService()

Get the service attached to this server.

Returns:
the service

String getURL()

Gets the URL of this server.

Returns:
the url

boolean isRunning(boolean traceError)

Checks if the server is running.

Parameters:
traceError - if errors should be written
Returns:
if the server is running

static void main(String[] args) throws SQLException

The command line interface for this tool. The options must be split into strings like this: "-baseDir", "/temp/data",... By default, -tcp, -web, -browser and -pg are started. If there is a problem starting a service, the program terminates with an exit code of 1. Options are case sensitive. The following options are supported:
  • -help or -? (print the list of options)
  • -web (start the Web Server and H2 Console)
  • -browser (start a browser and open a page to connect to the Web Server)
  • -tcp (start the TCP Server)
  • -tcpShutdown {url} (shutdown the running TCP Server, URL example: tcp://localhost:9094)
  • -pg (start the PG Server)
  • -ftp (start the FTP Server)
  • -trace (print additional trace information; for all servers)
  • -baseDir {directory} (sets the base directory for H2 databases; for all servers)
  • -ifExists (only existing databases may be opened; for all servers)
For each Server, additional options are available:
  • -webPort {port} (the port of Web Server, default: 8082)
  • -webSSL (HTTPS is to be be used)
  • -webAllowOthers (enable remote connections)
  • -tcpPort {port} (the port of TCP Server, default: 9092)
  • -tcpSSL (SSL is to be used)
  • -tcpAllowOthers (enable remote connections)
  • -tcpPassword {password} (the password for shutting down a TCP Server)
  • -tcpShutdownForce (don't wait for other connections to close)
  • -pgPort {port} (the port of PG Server, default: 5435)
  • -pgAllowOthers (enable remote connections)
  • -ftpPort {port}
  • -ftpDir {directory}
  • -ftpRead {readUserName}
  • -ftpWrite {writeUserName}
  • -ftpWritePassword {password}


Parameters:
args - the command line arguments
Throws:
SQLException

static void shutdownTcpServer(String url, String password, boolean force) throws SQLException

Shutdown a TCP server. If force is set to false, the server will not allow new connections, but not kill existing connections, instead it will stop if the last connection is closed. If force is set to true, existing connections are killed. After calling the method with force=false, it is not possible to call it again with force=true because new connections are not allowed. Example:
 Server.shutdownTcpServer("tcp://localhost:9094", password, true);


Parameters:
url - example: tcp://localhost:9094
password - the password to use ("" for no password)
force - the shutdown (don't wait)
Throws:
ClassNotFoundException
SQLException

Server start() throws SQLException

Tries to start the server.

Returns:
the server if successful
Throws:
SQLException - if the server could not be started

static void startWebServer(Connection conn) throws SQLException

Start a web server and a browser that uses the given connection. The current transaction is preserved. This is specially useful to manually inspect the database when debugging.

Parameters:
conn - the database connection (the database must be open)

void stop()

Stops the server.