Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e5c25628
提交
e5c25628
authored
17 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
b09fd536
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
81 行增加
和
55 行删除
+81
-55
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+4
-2
Console.java
h2/src/main/org/h2/tools/Console.java
+68
-39
Server.java
h2/src/main/org/h2/tools/Server.java
+1
-1
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+8
-2
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-11
没有找到文件。
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
e5c25628
...
@@ -132,8 +132,10 @@ public class WebServer implements Service {
...
@@ -132,8 +132,10 @@ public class WebServer implements Service {
// TODO web: support using a different properties file
// TODO web: support using a different properties file
appServer
=
new
AppServer
(
args
);
appServer
=
new
AppServer
(
args
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"EEE, d MMM yyyy HH:mm:ss z"
,
new
Locale
(
"en"
,
""
));
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"EEE, d MMM yyyy HH:mm:ss z"
,
new
Locale
(
"en"
,
""
));
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
));
synchronized
(
format
)
{
startDateTime
=
format
.
format
(
new
Date
());
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
));
startDateTime
=
format
.
format
(
new
Date
());
}
trace
(
startDateTime
);
trace
(
startDateTime
);
for
(
int
i
=
0
;
i
<
LANGUAGES
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
LANGUAGES
.
length
;
i
++)
{
languages
.
add
(
LANGUAGES
[
i
][
0
]);
languages
.
add
(
LANGUAGES
[
i
][
0
]);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Console.java
浏览文件 @
e5c25628
...
@@ -8,6 +8,7 @@ import java.awt.Button;
...
@@ -8,6 +8,7 @@ import java.awt.Button;
import
java.awt.Dimension
;
import
java.awt.Dimension
;
import
java.awt.Font
;
import
java.awt.Font
;
import
java.awt.Frame
;
import
java.awt.Frame
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.GridBagConstraints
;
import
java.awt.GridBagConstraints
;
import
java.awt.GridBagLayout
;
import
java.awt.GridBagLayout
;
import
java.awt.Image
;
import
java.awt.Image
;
...
@@ -26,8 +27,6 @@ import java.awt.event.WindowEvent;
...
@@ -26,8 +27,6 @@ import java.awt.event.WindowEvent;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.message.Message
;
import
org.h2.tools.Server
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StartBrowser
;
import
org.h2.util.StartBrowser
;
...
@@ -39,7 +38,8 @@ import org.h2.util.StartBrowser;
...
@@ -39,7 +38,8 @@ import org.h2.util.StartBrowser;
*/
*/
public
class
Console
implements
ActionListener
,
MouseListener
{
public
class
Console
implements
ActionListener
,
MouseListener
{
private
static
final
Font
FONT
=
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
11
);
private
Font
font
;
private
Image
icon
;
private
Server
web
;
private
Server
web
;
/**
/**
...
@@ -57,27 +57,48 @@ public class Console implements ActionListener, MouseListener {
...
@@ -57,27 +57,48 @@ public class Console implements ActionListener, MouseListener {
try
{
try
{
web
=
Server
.
createWebServer
(
args
);
web
=
Server
.
createWebServer
(
args
);
web
.
start
();
web
.
start
();
Server
.
createTcpServer
(
args
).
start
();
Server
.
createOdbcServer
(
args
).
start
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
if
(
e
.
getErrorCode
()
==
Message
.
EXCEPTION_OPENING_PORT_1
)
{
if
(
web
==
null
)
{
System
.
out
.
println
(
"Port is in use, maybe another server server already running on "
+
web
.
getURL
()
);
e
.
printStackTrace
(
);
}
else
{
}
else
{
e
.
printStackTrace
(
);
System
.
out
.
println
(
web
.
getStatus
()
);
}
}
}
}
Server
tcp
=
null
,
odbc
=
null
;
try
{
try
{
InputStream
in
=
getClass
().
getResourceAsStream
(
"/org/h2/res/h2.png"
);
tcp
=
Server
.
createTcpServer
(
args
);
Image
image
=
null
;
tcp
.
start
();
if
(
in
!=
null
)
{
}
catch
(
SQLException
e
)
{
byte
[]
imageData
=
IOUtils
.
readBytesAndClose
(
in
,
-
1
);
if
(
tcp
==
null
)
{
image
=
Toolkit
.
getDefaultToolkit
().
createImage
(
imageData
);
e
.
printStackTrace
();
}
}
else
{
if
(!
createTrayIcon
(
image
))
{
System
.
out
.
println
(
tcp
.
getStatus
());
showWindow
(
image
);
}
}
}
}
catch
(
Exception
e
)
{
try
{
e
.
printStackTrace
();
odbc
=
Server
.
createOdbcServer
(
args
);
odbc
.
start
();
}
catch
(
SQLException
e
)
{
if
(
odbc
==
null
)
{
e
.
printStackTrace
();
}
else
{
System
.
out
.
println
(
odbc
.
getStatus
());
}
}
if
(!
GraphicsEnvironment
.
isHeadless
())
{
font
=
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
11
);
try
{
InputStream
in
=
getClass
().
getResourceAsStream
(
"/org/h2/res/h2.png"
);
if
(
in
!=
null
)
{
byte
[]
imageData
=
IOUtils
.
readBytesAndClose
(
in
,
-
1
);
icon
=
Toolkit
.
getDefaultToolkit
().
createImage
(
imageData
);
}
if
(!
createTrayIcon
())
{
showWindow
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
// 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,
...
@@ -88,7 +109,7 @@ public class Console implements ActionListener, MouseListener {
...
@@ -88,7 +109,7 @@ public class Console implements ActionListener, MouseListener {
}
}
}
}
private
boolean
createTrayIcon
(
Image
image
)
{
private
boolean
createTrayIcon
()
{
try
{
try
{
// SystemTray.isSupported();
// SystemTray.isSupported();
Boolean
supported
=
(
Boolean
)
Class
.
forName
(
"java.awt.SystemTray"
).
Boolean
supported
=
(
Boolean
)
Class
.
forName
(
"java.awt.SystemTray"
).
...
@@ -103,33 +124,38 @@ public class Console implements ActionListener, MouseListener {
...
@@ -103,33 +124,38 @@ public class Console implements ActionListener, MouseListener {
MenuItem
itemConsole
=
new
MenuItem
(
"H2 Console"
);
MenuItem
itemConsole
=
new
MenuItem
(
"H2 Console"
);
itemConsole
.
setActionCommand
(
"console"
);
itemConsole
.
setActionCommand
(
"console"
);
itemConsole
.
addActionListener
(
this
);
itemConsole
.
addActionListener
(
this
);
itemConsole
.
setFont
(
FONT
);
itemConsole
.
setFont
(
font
);
menuConsole
.
add
(
itemConsole
);
menuConsole
.
add
(
itemConsole
);
MenuItem
itemStatus
=
new
MenuItem
(
"Status"
);
itemConsole
.
setActionCommand
(
"status"
);
itemConsole
.
addActionListener
(
this
);
itemConsole
.
setFont
(
font
);
menuConsole
.
add
(
itemStatus
);
MenuItem
itemExit
=
new
MenuItem
(
"Exit"
);
MenuItem
itemExit
=
new
MenuItem
(
"Exit"
);
itemExit
.
setFont
(
FONT
);
itemExit
.
setFont
(
font
);
itemExit
.
setActionCommand
(
"exit"
);
itemExit
.
setActionCommand
(
"exit"
);
itemExit
.
addActionListener
(
this
);
itemExit
.
addActionListener
(
this
);
menuConsole
.
add
(
itemExit
);
menuConsole
.
add
(
itemExit
);
// TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole);
// TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole);
Object
i
con
=
Class
.
forName
(
"java.awt.TrayIcon"
).
Object
trayI
con
=
Class
.
forName
(
"java.awt.TrayIcon"
).
getConstructor
(
new
Class
[]
{
Image
.
class
,
String
.
class
,
PopupMenu
.
class
}).
getConstructor
(
new
Class
[]
{
Image
.
class
,
String
.
class
,
PopupMenu
.
class
}).
newInstance
(
new
Object
[]
{
i
mage
,
"H2 Database Engine"
,
menuConsole
});
newInstance
(
new
Object
[]
{
i
con
,
"H2 Database Engine"
,
menuConsole
});
// SystemTray tray = SystemTray.getSystemTray();
// SystemTray tray = SystemTray.getSystemTray();
Object
tray
=
Class
.
forName
(
"java.awt.SystemTray"
).
Object
tray
=
Class
.
forName
(
"java.awt.SystemTray"
).
getMethod
(
"getSystemTray"
,
new
Class
[
0
]).
getMethod
(
"getSystemTray"
,
new
Class
[
0
]).
invoke
(
null
,
new
Object
[
0
]);
invoke
(
null
,
new
Object
[
0
]);
//
i
con.addMouseListener(this);
//
trayI
con.addMouseListener(this);
i
con
.
getClass
().
trayI
con
.
getClass
().
getMethod
(
"addMouseListener"
,
new
Class
[]{
MouseListener
.
class
}).
getMethod
(
"addMouseListener"
,
new
Class
[]{
MouseListener
.
class
}).
invoke
(
i
con
,
new
Object
[]{
this
});
invoke
(
trayI
con
,
new
Object
[]{
this
});
//
tray.add(icon);
// tray.add(icon);
tray
.
getClass
().
tray
.
getClass
().
getMethod
(
"add"
,
new
Class
[]
{
Class
.
forName
(
"java.awt.TrayIcon"
)
}).
getMethod
(
"add"
,
new
Class
[]
{
Class
.
forName
(
"java.awt.TrayIcon"
)
}).
invoke
(
tray
,
new
Object
[]
{
i
con
});
invoke
(
tray
,
new
Object
[]
{
trayI
con
});
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -137,15 +163,15 @@ public class Console implements ActionListener, MouseListener {
...
@@ -137,15 +163,15 @@ public class Console implements ActionListener, MouseListener {
}
}
}
}
private
void
showWindow
(
Image
image
)
{
private
void
showWindow
()
{
Frame
frame
=
new
Frame
(
"H2 Console"
);
Frame
frame
=
new
Frame
(
"H2 Console"
);
frame
.
addWindowListener
(
new
WindowAdapter
()
{
frame
.
addWindowListener
(
new
WindowAdapter
()
{
public
void
windowClosing
(
WindowEvent
we
)
{
public
void
windowClosing
(
WindowEvent
we
)
{
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
});
});
if
(
i
mage
!=
null
)
{
if
(
i
con
!=
null
)
{
frame
.
setIconImage
(
i
mage
);
frame
.
setIconImage
(
i
con
);
}
}
frame
.
setResizable
(
false
);
frame
.
setResizable
(
false
);
frame
.
setBackground
(
SystemColor
.
control
);
frame
.
setBackground
(
SystemColor
.
control
);
...
@@ -161,14 +187,14 @@ public class Console implements ActionListener, MouseListener {
...
@@ -161,14 +187,14 @@ public class Console implements ActionListener, MouseListener {
c
.
insets
.
bottom
=
2
;
c
.
insets
.
bottom
=
2
;
Label
label
=
new
Label
(
"H2 Console URL:"
,
Label
.
LEFT
);
Label
label
=
new
Label
(
"H2 Console URL:"
,
Label
.
LEFT
);
label
.
setFont
(
FONT
);
label
.
setFont
(
font
);
c
.
anchor
=
GridBagConstraints
.
WEST
;
c
.
anchor
=
GridBagConstraints
.
WEST
;
c
.
gridwidth
=
GridBagConstraints
.
EAST
;
c
.
gridwidth
=
GridBagConstraints
.
EAST
;
frame
.
add
(
label
,
c
);
frame
.
add
(
label
,
c
);
TextField
text
=
new
TextField
();
TextField
text
=
new
TextField
();
text
.
setEditable
(
false
);
text
.
setEditable
(
false
);
text
.
setFont
(
FONT
);
text
.
setFont
(
font
);
text
.
setText
(
web
.
getURL
());
text
.
setText
(
web
.
getURL
());
text
.
setFocusable
(
false
);
text
.
setFocusable
(
false
);
c
.
anchor
=
GridBagConstraints
.
EAST
;
c
.
anchor
=
GridBagConstraints
.
EAST
;
...
@@ -184,7 +210,7 @@ public class Console implements ActionListener, MouseListener {
...
@@ -184,7 +210,7 @@ public class Console implements ActionListener, MouseListener {
startBrowser
.
setFocusable
(
false
);
startBrowser
.
setFocusable
(
false
);
startBrowser
.
setActionCommand
(
"console"
);
startBrowser
.
setActionCommand
(
"console"
);
startBrowser
.
addActionListener
(
this
);
startBrowser
.
addActionListener
(
this
);
startBrowser
.
setFont
(
FONT
);
startBrowser
.
setFont
(
font
);
c
.
anchor
=
GridBagConstraints
.
EAST
;
c
.
anchor
=
GridBagConstraints
.
EAST
;
c
.
gridwidth
=
GridBagConstraints
.
REMAINDER
;
c
.
gridwidth
=
GridBagConstraints
.
REMAINDER
;
frame
.
add
(
startBrowser
,
c
);
frame
.
add
(
startBrowser
,
c
);
...
@@ -200,10 +226,13 @@ public class Console implements ActionListener, MouseListener {
...
@@ -200,10 +226,13 @@ public class Console implements ActionListener, MouseListener {
* INTERNAL
* INTERNAL
*/
*/
public
void
actionPerformed
(
ActionEvent
e
)
{
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
e
.
getActionCommand
().
equals
(
"exit"
))
{
String
command
=
e
.
getActionCommand
();
if
(
"exit"
.
equals
(
command
))
{
System
.
exit
(
0
);
System
.
exit
(
0
);
}
else
if
(
e
.
getActionCommand
().
equals
(
"console"
))
{
}
else
if
(
"console"
.
equals
(
command
))
{
startBrowser
();
startBrowser
();
}
else
if
(
"status"
.
equals
(
command
))
{
showWindow
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Server.java
浏览文件 @
e5c25628
...
@@ -271,7 +271,7 @@ public class Server implements Runnable {
...
@@ -271,7 +271,7 @@ public class Server implements Runnable {
}
}
}
}
private
String
getStatus
()
{
String
getStatus
()
{
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buff
=
new
StringBuffer
();
if
(
isRunning
())
{
if
(
isRunning
())
{
buff
.
append
(
service
.
getType
());
buff
.
append
(
service
.
getType
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
e5c25628
...
@@ -379,7 +379,9 @@ public class StringUtils {
...
@@ -379,7 +379,9 @@ public class StringUtils {
*/
*/
public
static
String
formatDateTime
(
Date
date
,
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
public
static
String
formatDateTime
(
Date
date
,
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
SimpleDateFormat
dateFormat
=
getDateFormat
(
format
,
locale
,
timezone
);
SimpleDateFormat
dateFormat
=
getDateFormat
(
format
,
locale
,
timezone
);
return
dateFormat
.
format
(
date
);
synchronized
(
dateFormat
)
{
return
dateFormat
.
format
(
date
);
}
}
}
/**
/**
...
@@ -388,7 +390,9 @@ public class StringUtils {
...
@@ -388,7 +390,9 @@ public class StringUtils {
public
static
Date
parseDateTime
(
String
date
,
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
public
static
Date
parseDateTime
(
String
date
,
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
SimpleDateFormat
dateFormat
=
getDateFormat
(
format
,
locale
,
timezone
);
SimpleDateFormat
dateFormat
=
getDateFormat
(
format
,
locale
,
timezone
);
try
{
try
{
return
dateFormat
.
parse
(
date
);
synchronized
(
dateFormat
)
{
return
dateFormat
.
parse
(
date
);
}
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
throw
Message
.
getSQLException
(
Message
.
PARSE_ERROR_1
,
date
);
throw
Message
.
getSQLException
(
Message
.
PARSE_ERROR_1
,
date
);
}
}
...
@@ -396,6 +400,8 @@ public class StringUtils {
...
@@ -396,6 +400,8 @@ public class StringUtils {
private
static
SimpleDateFormat
getDateFormat
(
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
private
static
SimpleDateFormat
getDateFormat
(
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
try
{
try
{
// currently, a new instance is create for each call
// however, could cache the last few instances
SimpleDateFormat
df
;
SimpleDateFormat
df
;
if
(
locale
==
null
)
{
if
(
locale
==
null
)
{
df
=
new
SimpleDateFormat
(
format
);
df
=
new
SimpleDateFormat
(
format
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
e5c25628
...
@@ -93,23 +93,12 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
...
@@ -93,23 +93,12 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
test
.
printSystem
();
test
.
printSystem
();
/*
/*
Newletter, newsfeed hochladen
SimpleDateFormat must be synchronized externally
call cast(null as null)
h2 console: headless mode
h2 console system tray: menu item to open window
h2 console system tray: menu item to open window
Set h2.indexNew to false
Set h2.indexNew to false
16 > 2007-06-17
testHalt
testHalt
support ~ dir
Mail http://sf.net/projects/samooha
Mail http://sf.net/projects/samooha
java.lang.Exception: query was too quick; result: 0 time:968
java.lang.Exception: query was too quick; result: 0 time:968
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论