public class Server extends Tool implements Runnable, ShutdownHandler
| Constructor and Description |
|---|
Server() |
Server(Service service,
String... args)
Create a new server for the given service.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
int |
getPort()
Gets the port this server is listening on.
|
Service |
getService()
Get the service attached to this server.
|
String |
getStatus()
Get the status of 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)
When running without options, -tcp, -web, -browser and -pg are started.
|
static void |
openBrowser(String url)
Open a new browser tab or window with the given URL.
|
void |
run()
INTERNAL
|
void |
runTool(String... args)
Run the tool with the given output stream and arguments.
|
void |
setShutdownHandler(ShutdownHandler shutdownHandler)
INTERNAL
|
void |
shutdown()
INTERNAL
|
static void |
shutdownTcpServer(String url,
String password,
boolean force,
boolean all)
Shutdown one or all 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.
|
isOption, printNoDatabaseFilesFound, setOut, showUsage, throwUnsupportedOptionpublic Server()
public Server(Service service, String... args) throws SQLException
service - the serviceargs - the command line argumentsSQLExceptionpublic static void main(String... args) throws SQLException
| [-help] or [-?] | Print the list of options |
| [-web] | Start the web server with the H2 Console |
| [-webAllowOthers] | Allow other computers to connect - see below |
| [-webDaemon] | Use a daemon thread |
| [-webPort <port>] | The port (default: 8082) |
| [-webSSL] | Use encrypted (HTTPS) connections |
| [-browser] | Start a browser connecting to the web server |
| [-tcp] | Start the TCP server |
| [-tcpAllowOthers] | Allow other computers to connect - see below |
| [-tcpDaemon] | Use a daemon thread |
| [-tcpPort <port>] | The port (default: 9092) |
| [-tcpSSL] | Use encrypted (SSL) connections |
| [-tcpPassword <pwd>] | The password for shutting down a TCP server |
| [-tcpShutdown "<url>"] | Stop the TCP server; example: tcp://localhost |
| [-tcpShutdownForce] | Do not wait until all connections are closed |
| [-pg] | Start the PG server |
| [-pgAllowOthers] | Allow other computers to connect - see below |
| [-pgDaemon] | Use a daemon thread |
| [-pgPort <port>] | The port (default: 5435) |
| [-properties "<dir>"] | Server properties (default: ~, disable: null) |
| [-baseDir <dir>] | The base directory for H2 databases (all servers) |
| [-ifExists] | Only existing databases may be opened (all servers) |
| [-trace] | Print additional trace information (all servers) |
args - the command line argumentsSQLExceptionpublic void runTool(String... args) throws SQLException
ToolrunTool in class Toolargs - the argument listSQLExceptionpublic static void shutdownTcpServer(String url, String password, boolean force, boolean all) throws SQLException
Server.shutdownTcpServer(
"tcp://localhost:9094", password, true, false);
url - example: tcp://localhost:9094password - the password to use ("" for no password)force - the shutdown (don't wait)all - whether all TCP servers that are running in the JVM
should be stoppedSQLExceptionpublic String getStatus()
public static Server createWebServer(String... args) throws SQLException
Server server = Server.createWebServer(
new String[] { "-trace" }).start();
args - the argument listSQLExceptionpublic static Server createTcpServer(String... args) throws SQLException
Server server = Server.createTcpServer(
new String[] { "-tcpAllowOthers" }).start();
args - the argument listSQLExceptionpublic static Server createPgServer(String... args) throws SQLException
Server server =
Server.createPgServer("-pgAllowOthers").start();
args - the argument listSQLExceptionpublic Server start() throws SQLException
SQLException - if the server could not be startedpublic boolean isRunning(boolean traceError)
traceError - if errors should be writtenpublic void stop()
public String getURL()
public int getPort()
public void setShutdownHandler(ShutdownHandler shutdownHandler)
public void shutdown()
shutdown in interface ShutdownHandlerpublic Service getService()
public static void openBrowser(String url) throws Exception
url - the URL to openExceptionpublic static void startWebServer(Connection conn) throws SQLException
conn - the database connection (the database must be open)SQLExceptionCopyright © 2012 JBoss by Red Hat. All Rights Reserved.