Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7d80f3dc
提交
7d80f3dc
authored
10月 03, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The Console tool now supports command line options to start things separately.
上级
5658558a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
96 行增加
和
21 行删除
+96
-21
Console.java
h2/src/main/org/h2/tools/Console.java
+96
-21
没有找到文件。
h2/src/main/org/h2/tools/Console.java
浏览文件 @
7d80f3dc
...
@@ -32,6 +32,7 @@ import java.awt.event.WindowEvent;
...
@@ -32,6 +32,7 @@ import java.awt.event.WindowEvent;
import
org.h2.util.Resources
;
import
org.h2.util.Resources
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintStream
;
//## AWT end ##
//## AWT end ##
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -68,40 +69,112 @@ ShutdownHandler {
...
@@ -68,40 +69,112 @@ ShutdownHandler {
* The command line options are the same as in the Server tool,
* The command line options are the same as in the Server tool,
* but this tool will always start the TCP, TCP and PG server.
* but this tool will always start the TCP, TCP and PG server.
* Options are case sensitive.
* Options are case sensitive.
*
*
* 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:
* <ul>
* <li>-help or -? (print the list of options) </li>
* <li>-web (start the Web Server and H2 Console) </li>
* <li>-tool (start the icon or window that allows to start a browser)</li>
* <li>-browser (start a browser and open a page to connect to the
* Web Server) </li>
* <li>-tcp (start the TCP Server) </li>
* <li>-pg (start the PG Server) </li>
* </ul>
* For each Server, additional options are available.
* Those options are the same as in the Server tool.
*
* @param args the command line arguments
* @param args the command line arguments
*/
*/
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
exitCode
=
new
Console
().
run
(
args
);
int
exitCode
=
new
Console
().
run
(
args
,
System
.
out
);
if
(
exitCode
!=
0
)
{
if
(
exitCode
!=
0
)
{
System
.
exit
(
exitCode
);
System
.
exit
(
exitCode
);
}
}
}
}
private
void
showUsage
(
PrintStream
out
)
{
out
.
println
(
"Starts H2 Console"
);
out
.
println
(
"By default, -web, -tool, -browser, -tcp, and -pg are started. Options are case sensitive."
);
out
.
println
(
"java "
+
getClass
().
getName
());
out
.
println
(
"-web Start the Web Server and H2 Console"
);
out
.
println
(
"-tool Start the icon or window that allows to start a browser (includes -web)"
);
out
.
println
(
"-browser Start a browser to connect to the H2 Console (includes -web)"
);
out
.
println
(
"-tcp Start the TCP Server"
);
out
.
println
(
"-pg Start the PG Server"
);
out
.
println
(
"See also http://h2database.com/javadoc/"
+
getClass
().
getName
().
replace
(
'.'
,
'/'
)
+
".html"
);
}
private
int
run
(
String
[]
args
)
{
private
int
run
(
String
[]
args
,
PrintStream
out
)
{
isWindows
=
SysProperties
.
getStringSetting
(
"os.name"
,
""
).
startsWith
(
"Windows"
);
isWindows
=
SysProperties
.
getStringSetting
(
"os.name"
,
""
).
startsWith
(
"Windows"
);
boolean
tcpStart
=
false
,
pgStart
=
false
,
webStart
=
false
,
toolStart
=
false
;
boolean
browserStart
=
false
;
boolean
startDefaultServers
=
true
;
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
length
;
i
++)
{
String
arg
=
args
[
i
];
if
(
arg
==
null
)
{
continue
;
}
else
if
(
"-?"
.
equals
(
arg
)
||
"-help"
.
equals
(
arg
))
{
showUsage
(
out
);
return
EXIT_ERROR
;
}
else
if
(
"-web"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
webStart
=
true
;
}
else
if
(
"-tool"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
webStart
=
true
;
toolStart
=
true
;
}
else
if
(
"-browser"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
webStart
=
true
;
browserStart
=
true
;
}
else
if
(
"-tcp"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
tcpStart
=
true
;
}
else
if
(
"-pg"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
pgStart
=
true
;
}
}
if
(
startDefaultServers
)
{
webStart
=
true
;
toolStart
=
true
;
browserStart
=
true
;
tcpStart
=
true
;
pgStart
=
true
;
}
int
exitCode
=
0
;
int
exitCode
=
0
;
try
{
if
(
webStart
)
{
web
=
Server
.
createWebServer
(
args
);
try
{
web
.
setShutdownHandler
(
this
);
web
=
Server
.
createWebServer
(
args
);
web
.
start
();
web
.
setShutdownHandler
(
this
);
}
catch
(
SQLException
e
)
{
web
.
start
();
printProblem
(
e
,
web
);
}
catch
(
SQLException
e
)
{
printProblem
(
e
,
web
);
}
}
}
try
{
if
(
tcpStart
)
{
tcp
=
Server
.
createTcpServer
(
args
);
try
{
tcp
.
start
();
tcp
=
Server
.
createTcpServer
(
args
);
}
catch
(
SQLException
e
)
{
tcp
.
start
();
printProblem
(
e
,
tcp
);
}
catch
(
SQLException
e
)
{
printProblem
(
e
,
tcp
);
}
}
}
try
{
if
(
pgStart
)
{
pg
=
Server
.
createPgServer
(
args
);
try
{
pg
.
start
();
pg
=
Server
.
createPgServer
(
args
);
}
catch
(
SQLException
e
)
{
pg
.
start
();
printProblem
(
e
,
pg
);
}
catch
(
SQLException
e
)
{
printProblem
(
e
,
pg
);
}
}
}
//## AWT begin ##
//## AWT begin ##
if
(!
GraphicsEnvironment
.
isHeadless
())
{
if
(
toolStart
&&
!
GraphicsEnvironment
.
isHeadless
())
{
if
(
isWindows
)
{
if
(
isWindows
)
{
font
=
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
11
);
font
=
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
11
);
}
else
{
}
else
{
...
@@ -122,7 +195,9 @@ ShutdownHandler {
...
@@ -122,7 +195,9 @@ ShutdownHandler {
// start browser anyway (even if the server is already running)
// start browser anyway (even if the server is already running)
// because some people don't look at the output,
// because some people don't look at the output,
// but are wondering why nothing happens
// but are wondering why nothing happens
StartBrowser
.
openURL
(
web
.
getURL
());
if
(
browserStart
)
{
StartBrowser
.
openURL
(
web
.
getURL
());
}
if
(!
web
.
isRunning
(
true
))
{
if
(!
web
.
isRunning
(
true
))
{
exitCode
=
EXIT_ERROR
;
exitCode
=
EXIT_ERROR
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论