提交 e3d97902 authored 作者: Thomas Mueller's avatar Thomas Mueller

The H2 Console tool now supports a database URL as a command line option.

上级 d2178c99
......@@ -20,7 +20,7 @@ org.h2.tools.Backup.main=Options are case sensitive. Supported options are\:\n[-
org.h2.tools.ChangeFileEncryption=Allows changing the database file encryption password or algorithm.\nThis tool can not be used to change a password of a user.\n The database must be closed before using this tool.
org.h2.tools.ChangeFileEncryption.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-cipher type] The encryption type (AES or XTEA)\n[-dir <dir>] The database directory (default\: .)\n[-db <database>] Database name (all databases if not set)\n[-decrypt <pwd>] The decryption password (if not set\: not yet encrypted)\n[-encrypt <pwd>] The encryption password (if not set\: do not encrypt)\n[-quiet] Do not print progress information
org.h2.tools.Console=Starts the H2 Console (web-) server, as well as the TCP and PG server.
org.h2.tools.Console.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-tool] Start the icon or window that allows to start a browser\n[-browser] Start a browser connecting to the web server\n[-tcp] Start the TCP server\n[-pg] Start the PG server\nFor each Server, additional options are available;\n for details, see the Server tool.\nIf a service can not be started, the program\n terminates with an exit code of 1.
org.h2.tools.Console.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url] Start a browser and connect to this URL\n[-driver] Used together with -url\: the driver\n[-user] Used together with -url\: the user name\n[-password] Used together with -url\: the password\n[-web] Start the web server with the H2 Console\n[-tool] Start the icon or window that allows to start a browser\n[-browser] Start a browser connecting to the web server\n[-tcp] Start the TCP server\n[-pg] Start the PG server\nFor each Server, additional options are available;\n for details, see the Server tool.\nIf a service can not be started, the program\n terminates with an exit code of 1.
org.h2.tools.ConvertTraceFile=Converts a .trace.db file to a SQL script and Java source code.\nSQL statement statistics are listed as well.
org.h2.tools.ConvertTraceFile.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-traceFile <file>] The trace file name (default\: test.trace.db)\n[-script <file>] The script file name (default\: test.sql)\n[-javaClass <file>] The Java directory and class file name (default\: Test)
org.h2.tools.CreateCluster=Creates a cluster from a standalone database.\nCopies a database to another location if required.
......
......@@ -30,9 +30,11 @@ import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import org.h2.constant.SysProperties;
import org.h2.server.ShutdownHandler;
import org.h2.util.JdbcUtils;
import org.h2.util.Tool;
import org.h2.util.Utils;
......@@ -68,6 +70,14 @@ ShutdownHandler {
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-url]</td>
* <td>Start a browser and connect to this URL</td></tr>
* <tr><td>[-driver]</td>
* <td>Used together with -url: the driver</td></tr>
* <tr><td>[-user]</td>
* <td>Used together with -url: the user name</td></tr>
* <tr><td>[-password]</td>
* <td>Used together with -url: the password</td></tr>
* <tr><td>[-web]</td>
* <td>Start the web server with the H2 Console</td></tr>
* <tr><td>[-tool]</td>
......@@ -104,6 +114,7 @@ ShutdownHandler {
boolean browserStart = false;
boolean startDefaultServers = true;
boolean printStatus = args != null && args.length > 0;
String driver = null, url = null, user = null, password = null;
for (int i = 0; args != null && i < args.length; i++) {
String arg = args[i];
......@@ -112,6 +123,15 @@ ShutdownHandler {
} else if ("-?".equals(arg) || "-help".equals(arg)) {
showUsage();
return;
} else if ("-url".equals(arg)) {
startDefaultServers = false;
url = args[++i];
} else if ("-driver".equals(arg)) {
driver = args[++i];
} else if ("-user".equals(arg)) {
user = args[++i];
} else if ("-password".equals(arg)) {
password = args[++i];
} else if ("-web".equals(arg)) {
startDefaultServers = false;
webStart = true;
......@@ -140,6 +160,12 @@ ShutdownHandler {
}
SQLException startException = null;
boolean webRunning = false;
if (url != null) {
Connection conn = JdbcUtils.getConnection(driver, url, user, password);
Server.startWebServer(conn);
}
if (webStart) {
try {
web = Server.createWebServer(args);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论