Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
20037a4a
提交
20037a4a
authored
3月 30, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The API of the tools changed a bit.
上级
6ab81676
全部展开
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
190 行增加
和
283 行删除
+190
-283
Backup.java
h2/src/main/org/h2/tools/Backup.java
+1
-3
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+2
-4
Console.java
h2/src/main/org/h2/tools/Console.java
+38
-53
ConvertTraceFile.java
h2/src/main/org/h2/tools/ConvertTraceFile.java
+1
-3
CreateCluster.java
h2/src/main/org/h2/tools/CreateCluster.java
+3
-5
DeleteDbFiles.java
h2/src/main/org/h2/tools/DeleteDbFiles.java
+1
-3
Recover.java
h2/src/main/org/h2/tools/Recover.java
+2
-3
Restore.java
h2/src/main/org/h2/tools/Restore.java
+1
-3
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+3
-5
Script.java
h2/src/main/org/h2/tools/Script.java
+2
-4
Server.java
h2/src/main/org/h2/tools/Server.java
+84
-140
Shell.java
h2/src/main/org/h2/tools/Shell.java
+35
-48
TestShell.java
h2/src/test/org/h2/test/unit/TestShell.java
+3
-1
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+8
-2
FileViewer.java
h2/src/tools/org/h2/dev/util/FileViewer.java
+6
-6
没有找到文件。
h2/src/main/org/h2/tools/Backup.java
浏览文件 @
20037a4a
...
@@ -70,9 +70,7 @@ public class Backup extends Tool {
...
@@ -70,9 +70,7 @@ public class Backup extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
process
(
zipFileName
,
dir
,
db
,
quiet
);
process
(
zipFileName
,
dir
,
db
,
quiet
);
...
...
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
20037a4a
...
@@ -80,14 +80,12 @@ public class ChangeFileEncryption extends Tool {
...
@@ -80,14 +80,12 @@ public class ChangeFileEncryption extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
((
encryptPassword
==
null
&&
decryptPassword
==
null
)
||
cipher
==
null
)
{
if
((
encryptPassword
==
null
&&
decryptPassword
==
null
)
||
cipher
==
null
)
{
showUsage
();
showUsage
();
return
;
throw
new
SQLException
(
"Encryption or decryption password not set, or cipher not set"
)
;
}
}
process
(
dir
,
db
,
cipher
,
decryptPassword
,
encryptPassword
,
quiet
);
process
(
dir
,
db
,
cipher
,
decryptPassword
,
encryptPassword
,
quiet
);
}
}
...
...
h2/src/main/org/h2/tools/Console.java
浏览文件 @
20037a4a
...
@@ -30,9 +30,9 @@ import java.awt.event.MouseListener;
...
@@ -30,9 +30,9 @@ import java.awt.event.MouseListener;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowEvent
;
import
org.h2.util.Resources
;
import
org.h2.util.Resources
;
import
org.h2.util.Tool
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintStream
;
//## AWT end ##
//## AWT end ##
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -41,20 +41,17 @@ import org.h2.server.ShutdownHandler;
...
@@ -41,20 +41,17 @@ import org.h2.server.ShutdownHandler;
import
org.h2.util.StartBrowser
;
import
org.h2.util.StartBrowser
;
/**
/**
* This tool starts the H2 Console (web-) server, as well as the TCP and PG
* Starts the H2 Console (web-) server, as well as the TCP and PG server.
* server. For JDK 1.6, a system tray icon is created, for platforms that
* @h2.resource
* support it. Otherwise, a small window opens.
*
*
* @author Thomas Mueller, Ridvan Agar
* @author Thomas Mueller, Ridvan Agar
*/
*/
public
class
Console
implements
public
class
Console
extends
Tool
implements
//## AWT begin ##
//## AWT begin ##
ActionListener
,
MouseListener
,
ActionListener
,
MouseListener
,
//## AWT end ##
//## AWT end ##
ShutdownHandler
{
ShutdownHandler
{
private
static
final
int
EXIT_ERROR
=
1
;
//## AWT begin ##
//## AWT begin ##
Frame
frame
;
Frame
frame
;
private
Font
font
;
private
Font
font
;
...
@@ -65,50 +62,40 @@ ShutdownHandler {
...
@@ -65,50 +62,40 @@ ShutdownHandler {
private
boolean
isWindows
;
private
boolean
isWindows
;
/**
/**
* The command line interface for this tool.
* When running without options, -tcp, -web, -browser and -pg are started.<br />
* The command line options are the same as in the Server tool,
* Options are case sensitive. Supported options are:
* but this tool will always start the TCP, TCP and PG server.
* <table>
* Options are case sensitive.
* <tr><td>[-help] or [-?]</td>
*
* <td>Print the list of options</td></tr>
* The command line interface for this tool. The options must be split into
* <tr><td>[-web]</td>
* strings like this: "-baseDir", "/temp/data",... By default, -tcp, -web,
* <td>Start the web server with the H2 Console</td></tr>
* -browser and -pg are started. If there is a problem starting a service,
* <tr><td>[-tool]</td>
* the program terminates with an exit code of 1. Options are case
* <td>Start the icon or window that allows to start a browser</td></tr>
* sensitive. The following options are supported:
* <tr><td>[-browser]</td>
* <ul>
* <td>Start a browser and open a page to connect to the web server</td></tr>
* <li>-help or -? (print the list of options) </li>
* <tr><td>[-tcp]</td>
* <li>-web (start the Web Server and H2 Console) </li>
* <td>Start the TCP server</td></tr>
* <li>-tool (start the icon or window that allows to start a browser)</li>
* <tr><td>[-pg]</td>
* <li>-browser (start a browser and open a page to connect to the
* <td>Start the PG server</td></tr>
* Web Server) </li>
* </table>
* <li>-tcp (start the TCP Server) </li>
* For each Server, additional options are available; for details, see the Server tool.<br />
* <li>-pg (start the PG Server) </li>
* If a service can not be started, the program terminates with an exit code of 1.
* </ul>
* @h2.resource
* 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
)
throws
SQLException
{
int
exitCode
=
new
Console
().
run
(
args
,
System
.
out
);
new
Console
().
run
(
args
);
if
(
exitCode
!=
0
)
{
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
,
PrintStream
out
)
{
/**
* This tool starts the H2 Console (web-) server, as well as the TCP and PG
* server. For JDK 1.6, a system tray icon is created, for platforms that
* support it. Otherwise, a small window opens.
*
* @param args the command line arguments
*/
public
void
run
(
String
[]
args
)
throws
SQLException
{
isWindows
=
SysProperties
.
getStringSetting
(
"os.name"
,
""
).
startsWith
(
"Windows"
);
isWindows
=
SysProperties
.
getStringSetting
(
"os.name"
,
""
).
startsWith
(
"Windows"
);
boolean
tcpStart
=
false
,
pgStart
=
false
,
webStart
=
false
,
toolStart
=
false
;
boolean
tcpStart
=
false
,
pgStart
=
false
,
webStart
=
false
,
toolStart
=
false
;
boolean
browserStart
=
false
;
boolean
browserStart
=
false
;
...
@@ -119,8 +106,8 @@ ShutdownHandler {
...
@@ -119,8 +106,8 @@ ShutdownHandler {
if
(
arg
==
null
)
{
if
(
arg
==
null
)
{
continue
;
continue
;
}
else
if
(
"-?"
.
equals
(
arg
)
||
"-help"
.
equals
(
arg
))
{
}
else
if
(
"-?"
.
equals
(
arg
)
||
"-help"
.
equals
(
arg
))
{
showUsage
(
out
);
showUsage
();
return
EXIT_ERROR
;
return
;
}
else
if
(
"-web"
.
equals
(
arg
))
{
}
else
if
(
"-web"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
startDefaultServers
=
false
;
webStart
=
true
;
webStart
=
true
;
...
@@ -147,7 +134,6 @@ ShutdownHandler {
...
@@ -147,7 +134,6 @@ ShutdownHandler {
tcpStart
=
true
;
tcpStart
=
true
;
pgStart
=
true
;
pgStart
=
true
;
}
}
int
exitCode
=
0
;
if
(
webStart
)
{
if
(
webStart
)
{
try
{
try
{
web
=
Server
.
createWebServer
(
args
);
web
=
Server
.
createWebServer
(
args
);
...
@@ -199,17 +185,16 @@ ShutdownHandler {
...
@@ -199,17 +185,16 @@ ShutdownHandler {
StartBrowser
.
openURL
(
web
.
getURL
());
StartBrowser
.
openURL
(
web
.
getURL
());
}
}
if
(!
web
.
isRunning
(
true
))
{
if
(!
web
.
isRunning
(
true
))
{
exitCode
=
EXIT_ERROR
;
throw
new
SQLException
(
"The web server is not running"
)
;
}
}
return
exitCode
;
}
}
private
void
printProblem
(
SQLException
e
,
Server
server
)
{
private
void
printProblem
(
SQLException
e
,
Server
server
)
{
if
(
server
==
null
)
{
if
(
server
==
null
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
else
{
}
else
{
System
.
out
.
println
(
server
.
getStatus
());
out
.
println
(
server
.
getStatus
());
System
.
out
.
println
(
"Root cause: "
+
e
.
getMessage
());
out
.
println
(
"Root cause: "
+
e
.
getMessage
());
}
}
}
}
...
...
h2/src/main/org/h2/tools/ConvertTraceFile.java
浏览文件 @
20037a4a
...
@@ -92,9 +92,7 @@ public class ConvertTraceFile extends Tool {
...
@@ -92,9 +92,7 @@ public class ConvertTraceFile extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
try
{
try
{
...
...
h2/src/main/org/h2/tools/CreateCluster.java
浏览文件 @
20037a4a
...
@@ -69,14 +69,12 @@ public class CreateCluster extends Tool {
...
@@ -69,14 +69,12 @@ public class CreateCluster extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
(
urlSource
==
null
||
urlTarget
==
null
||
user
==
null
||
serverList
==
null
)
{
if
(
urlSource
==
null
||
urlTarget
==
null
||
serverList
==
null
)
{
showUsage
();
showUsage
();
return
;
throw
new
SQLException
(
"Source URL, target URL, or server list not set"
)
;
}
}
process
(
urlSource
,
urlTarget
,
user
,
password
,
serverList
);
process
(
urlSource
,
urlTarget
,
user
,
password
,
serverList
);
}
}
...
...
h2/src/main/org/h2/tools/DeleteDbFiles.java
浏览文件 @
20037a4a
...
@@ -59,9 +59,7 @@ public class DeleteDbFiles extends Tool {
...
@@ -59,9 +59,7 @@ public class DeleteDbFiles extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
process
(
dir
,
db
,
quiet
);
process
(
dir
,
db
,
quiet
);
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
20037a4a
...
@@ -106,6 +106,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -106,6 +106,7 @@ public class Recover extends Tool implements DataHandler {
* a hardware problem.
* a hardware problem.
*
*
* @param args the command line arguments
* @param args the command line arguments
* @return the exit code
*/
*/
public
void
run
(
String
[]
args
)
throws
SQLException
{
public
void
run
(
String
[]
args
)
throws
SQLException
{
String
dir
=
"."
;
String
dir
=
"."
;
...
@@ -124,9 +125,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -124,9 +125,7 @@ public class Recover extends Tool implements DataHandler {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
(!
SysProperties
.
PAGE_STORE
&&
remove
)
{
if
(!
SysProperties
.
PAGE_STORE
&&
remove
)
{
...
...
h2/src/main/org/h2/tools/Restore.java
浏览文件 @
20037a4a
...
@@ -66,9 +66,7 @@ public class Restore extends Tool {
...
@@ -66,9 +66,7 @@ public class Restore extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
process
(
zipFileName
,
dir
,
db
);
process
(
zipFileName
,
dir
,
db
);
...
...
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
20037a4a
...
@@ -127,14 +127,12 @@ public class RunScript extends Tool {
...
@@ -127,14 +127,12 @@ public class RunScript extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
(
url
==
null
||
user
==
null
||
password
==
null
||
script
==
null
)
{
if
(
url
==
null
)
{
showUsage
();
showUsage
();
return
;
throw
new
SQLException
(
"URL not set"
)
;
}
}
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
if
(
options
!=
null
)
{
if
(
options
!=
null
)
{
...
...
h2/src/main/org/h2/tools/Script.java
浏览文件 @
20037a4a
...
@@ -89,14 +89,12 @@ public class Script extends Tool {
...
@@ -89,14 +89,12 @@ public class Script extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
(
url
==
null
)
{
if
(
url
==
null
)
{
showUsage
();
showUsage
();
return
;
throw
new
SQLException
(
"URL not set"
)
;
}
}
if
(
options1
!=
null
)
{
if
(
options1
!=
null
)
{
processScript
(
url
,
user
,
password
,
file
,
options1
,
options2
);
processScript
(
url
,
user
,
password
,
file
,
options1
,
options2
);
...
...
h2/src/main/org/h2/tools/Server.java
浏览文件 @
20037a4a
差异被折叠。
点击展开。
h2/src/main/org/h2/tools/Shell.java
浏览文件 @
20037a4a
...
@@ -28,83 +28,71 @@ import org.h2.util.FileUtils;
...
@@ -28,83 +28,71 @@ import org.h2.util.FileUtils;
import
org.h2.util.JdbcDriverUtils
;
import
org.h2.util.JdbcDriverUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.SortedProperties
;
import
org.h2.util.SortedProperties
;
import
org.h2.util.Tool
;
/**
/**
* Interactive command line tool to access a database using JDBC.
* Interactive command line tool to access a database using JDBC.
* @h2.resource
*/
*/
public
class
Shell
{
public
class
Shell
extends
Tool
{
/**
* The system output stream.
*/
PrintStream
out
=
System
.
out
;
private
PrintStream
err
=
System
.
err
;
private
PrintStream
err
=
System
.
err
;
private
InputStream
in
=
System
.
in
;
private
InputStream
in
=
System
.
in
;
private
BufferedReader
reader
;
private
Connection
conn
;
private
Connection
conn
;
private
Statement
stat
;
private
Statement
stat
;
private
boolean
listMode
;
private
boolean
listMode
;
private
int
maxColumnSize
=
100
;
private
int
maxColumnSize
=
100
;
// Windows: '\u00b3';
// Windows: '\u00b3';
private
char
boxVertical
=
'|'
;
private
char
boxVertical
=
'|'
;
private
BufferedReader
reader
;
/**
/**
* The command line interface for this tool. The options must be split into
* Options are case sensitive. Supported options are:
* strings like this: "-user", "sa",... Options are case sensitive. The
* <table>
* following options are supported:
* <tr><td>[-help] or [-?]</td>
* <ul>
* <td>Print the list of options</td></tr>
* <li>-help or -? (print the list of options) </li>
* <tr><td>[-url <url>]</td>
* <li>-url jdbc:h2:... (database URL) </li>
* <td>The database URL (jdbc:h2:...)</td></tr>
* <li>-user username </li>
* <tr><td>[-user <user>]</td>
* <li>-password password </li>
* <td>The user name</td></tr>
* <li>-driver driver the JDBC driver class name (not required for most
* <tr><td>[-password <pwd>]</td>
* databases) </li>
* <td>The password</td></tr>
* </ul>
* <tr><td>[-driver <class>]</td>
* <td>The JDBC driver class to use (not required in most cases)</td></tr>
* </table>
* @h2.resource
*
*
* @param args the command line arguments
* @param args the command line arguments
* @throws SQLException
*/
*/
public
static
void
main
(
String
[]
args
)
throws
SQLException
{
public
static
void
main
(
String
[]
args
)
throws
SQLException
{
new
Shell
().
run
(
args
);
new
Shell
().
run
(
args
);
}
}
private
void
showUsage
()
{
/**
println
(
"An interactive command line database tool."
);
* Sets the standard error stream.
println
(
"java "
+
getClass
().
getName
()
+
"\n"
+
*
" [-url <url>] The database URL\n"
+
* @param out the new standard error stream
" [-user <user>] The user name\n"
+
*/
" [-password <pwd>] The password\n"
+
public
void
setErr
(
PrintStream
err
)
{
" [-driver <class>] The JDBC driver class to use (not required in most cases)"
);
this
.
err
=
err
;
println
(
"See also http://h2database.com/javadoc/"
+
getClass
().
getName
().
replace
(
'.'
,
'/'
)
+
".html"
);
}
}
/**
/**
* Redirects the input and output. By default, System.in, out and err are
* Redirects the standard input. By default, System.in is used.
* used.
*
*
* @param in the input stream to use
* @param in the input stream to use
* @param out the output stream to use
* @param err the output error stream to use
*/
*/
public
void
set
Streams
(
InputStream
in
,
PrintStream
out
,
PrintStream
err
)
{
public
void
set
In
(
InputStream
in
)
{
this
.
in
=
in
;
this
.
in
=
in
;
this
.
out
=
out
;
this
.
err
=
err
;
}
}
/**
/**
* Redirects the input and output. By default, System.in, out and err are
* Redirects the standard input. By default, System.in is used.
* used.
*
*
* @param reader the input stream reader to use
* @param reader the input stream reader to use
* @param out the output stream to use
* @param err the output error stream to use
*/
*/
public
void
set
Streams
(
BufferedReader
reader
,
PrintStream
out
,
PrintStream
er
r
)
{
public
void
set
InReader
(
BufferedReader
reade
r
)
{
this
.
reader
=
reader
;
this
.
reader
=
reader
;
this
.
out
=
out
;
this
.
err
=
err
;
}
}
/**
/**
...
@@ -117,19 +105,18 @@ public class Shell {
...
@@ -117,19 +105,18 @@ public class Shell {
String
user
=
""
;
String
user
=
""
;
String
password
=
""
;
String
password
=
""
;
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
length
;
i
++)
{
if
(
args
[
i
].
equals
(
"-url"
))
{
String
arg
=
args
[
i
];
if
(
arg
.
equals
(
"-url"
))
{
url
=
args
[++
i
];
url
=
args
[++
i
];
}
else
if
(
arg
s
[
i
]
.
equals
(
"-user"
))
{
}
else
if
(
arg
.
equals
(
"-user"
))
{
user
=
args
[++
i
];
user
=
args
[++
i
];
}
else
if
(
arg
s
[
i
]
.
equals
(
"-password"
))
{
}
else
if
(
arg
.
equals
(
"-password"
))
{
password
=
args
[++
i
];
password
=
args
[++
i
];
}
else
if
(
arg
s
[
i
]
.
equals
(
"-driver"
))
{
}
else
if
(
arg
.
equals
(
"-driver"
))
{
String
driver
=
args
[++
i
];
String
driver
=
args
[++
i
];
ClassUtils
.
loadUserClass
(
driver
);
ClassUtils
.
loadUserClass
(
driver
);
}
else
{
}
else
{
println
(
"Unsupported option: "
+
args
[
i
]);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
(
url
!=
null
)
{
if
(
url
!=
null
)
{
...
...
h2/src/test/org/h2/test/unit/TestShell.java
浏览文件 @
20037a4a
...
@@ -57,7 +57,9 @@ public class TestShell extends TestBase {
...
@@ -57,7 +57,9 @@ public class TestShell extends TestBase {
public
void
run
()
{
public
void
run
()
{
try
{
try
{
Shell
shell
=
new
Shell
();
Shell
shell
=
new
Shell
();
shell
.
setStreams
(
toolIn
,
toolOut
,
toolOut
);
shell
.
setIn
(
toolIn
);
shell
.
setOut
(
toolOut
);
shell
.
setErr
(
toolOut
);
shell
.
run
(
new
String
[
0
]);
shell
.
run
(
new
String
[
0
]);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
20037a4a
...
@@ -162,8 +162,14 @@ public class TestTools extends TestBase {
...
@@ -162,8 +162,14 @@ public class TestTools extends TestBase {
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
PrintStream
ps
=
new
PrintStream
(
buff
);
PrintStream
ps
=
new
PrintStream
(
buff
);
server
=
new
Server
();
server
=
new
Server
();
int
gotCode
=
server
.
run
(
args
,
ps
);
server
.
setOut
(
ps
);
assertEquals
(
exitCode
,
gotCode
);
int
result
=
0
;
try
{
server
.
run
(
args
);
}
catch
(
SQLException
e
)
{
result
=
1
;
}
assertEquals
(
exitCode
,
result
);
ps
.
flush
();
ps
.
flush
();
String
s
=
new
String
(
buff
.
toByteArray
());
String
s
=
new
String
(
buff
.
toByteArray
());
return
s
;
return
s
;
...
...
h2/src/tools/org/h2/dev/util/FileViewer.java
浏览文件 @
20037a4a
...
@@ -9,8 +9,10 @@ package org.h2.dev.util;
...
@@ -9,8 +9,10 @@ package org.h2.dev.util;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.RandomAccessFile
;
import
java.io.RandomAccessFile
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.message.Message
;
import
org.h2.util.Tool
;
import
org.h2.util.Tool
;
...
@@ -24,7 +26,7 @@ public class FileViewer extends Tool {
...
@@ -24,7 +26,7 @@ public class FileViewer extends Tool {
*
*
* @param args the command line arguments
* @param args the command line arguments
*/
*/
public
static
void
main
(
String
[]
args
)
throws
IO
Exception
{
public
static
void
main
(
String
[]
args
)
throws
SQL
Exception
{
new
FileViewer
().
run
(
args
);
new
FileViewer
().
run
(
args
);
}
}
...
@@ -42,7 +44,7 @@ public class FileViewer extends Tool {
...
@@ -42,7 +44,7 @@ public class FileViewer extends Tool {
// getClass().getName().replace('.', '/') + ".html");
// getClass().getName().replace('.', '/') + ".html");
}
}
public
void
run
(
String
[]
args
)
{
public
void
run
(
String
[]
args
)
throws
SQLException
{
String
file
=
null
;
String
file
=
null
;
String
find
=
null
;
String
find
=
null
;
boolean
head
=
false
,
tail
=
false
;
boolean
head
=
false
,
tail
=
false
;
...
@@ -69,9 +71,7 @@ public class FileViewer extends Tool {
...
@@ -69,9 +71,7 @@ public class FileViewer extends Tool {
showUsage
();
showUsage
();
return
;
return
;
}
else
{
}
else
{
out
.
println
(
"Unsupported option: "
+
arg
);
throwUnsupportedOption
(
arg
);
showUsage
();
return
;
}
}
}
}
if
(
file
==
null
)
{
if
(
file
==
null
)
{
...
@@ -84,7 +84,7 @@ public class FileViewer extends Tool {
...
@@ -84,7 +84,7 @@ public class FileViewer extends Tool {
try
{
try
{
process
(
file
,
find
,
head
,
tail
,
start
,
lines
,
quiet
);
process
(
file
,
find
,
head
,
tail
,
start
,
lines
,
quiet
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
);
throw
Message
.
convert
(
e
);
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论