Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
35e27cd5
提交
35e27cd5
authored
7月 27, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
4fe8ae0d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
43 个修改的文件
包含
672 行增加
和
310 行删除
+672
-310
ant-build.properties
h2/ant-build.properties
+1
-1
build.xml
h2/build.xml
+1
-0
advanced.html
h2/src/docsrc/html/advanced.html
+16
-14
build.html
h2/src/docsrc/html/build.html
+4
-2
download.html
h2/src/docsrc/html/download.html
+8
-3
faq.html
h2/src/docsrc/html/faq.html
+6
-4
features.html
h2/src/docsrc/html/features.html
+4
-2
history.html
h2/src/docsrc/html/history.html
+14
-7
installation.html
h2/src/docsrc/html/installation.html
+4
-2
main.html
h2/src/docsrc/html/main.html
+4
-2
mainWeb_text_.html
h2/src/docsrc/html/mainWeb_text_.html
+2
-2
performance.html
h2/src/docsrc/html/performance.html
+6
-4
quickstartText.html
h2/src/docsrc/html/quickstartText.html
+6
-4
tutorial.html
h2/src/docsrc/html/tutorial.html
+23
-5
Driver.java
h2/src/main/org/h2/Driver.java
+2
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+156
-85
TransactionCommand.java
h2/src/main/org/h2/command/dml/TransactionCommand.java
+4
-0
Constants.java
h2/src/main/org/h2/engine/Constants.java
+1
-1
Mode.java
h2/src/main/org/h2/engine/Mode.java
+6
-0
Session.java
h2/src/main/org/h2/engine/Session.java
+14
-0
CompareLike.java
h2/src/main/org/h2/expression/CompareLike.java
+31
-5
Function.java
h2/src/main/org/h2/expression/Function.java
+4
-1
help.csv
h2/src/main/org/h2/res/help.csv
+16
-1
PgServer.java
h2/src/main/org/h2/server/pg/PgServer.java
+5
-3
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+80
-44
pg_catalog.sql
h2/src/main/org/h2/server/pg/pg_catalog.sql
+26
-55
Console.java
h2/src/main/org/h2/tools/Console.java
+11
-1
Server.java
h2/src/main/org/h2/tools/Server.java
+33
-1
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+4
-3
ValueStringIgnoreCase.java
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
+5
-0
MixedMode.java
h2/src/test/org/h2/samples/MixedMode.java
+42
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+26
-6
BenchA.java
h2/src/test/org/h2/test/bench/BenchA.java
+7
-7
BenchB.java
h2/src/test/org/h2/test/bench/BenchB.java
+3
-3
BenchC.java
h2/src/test/org/h2/test/bench/BenchC.java
+9
-11
BenchCThread.java
h2/src/test/org/h2/test/bench/BenchCThread.java
+17
-17
BenchSimple.java
h2/src/test/org/h2/test/bench/BenchSimple.java
+3
-3
Database.java
h2/src/test/org/h2/test/bench/Database.java
+6
-1
TestPerformance.java
h2/src/test/org/h2/test/bench/TestPerformance.java
+9
-0
test.properties
h2/src/test/org/h2/test/bench/test.properties
+10
-7
test.in.txt
h2/src/test/org/h2/test/test.in.txt
+24
-0
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+18
-0
TestPattern.java
h2/src/test/org/h2/test/unit/TestPattern.java
+1
-1
没有找到文件。
h2/ant-build.properties
浏览文件 @
35e27cd5
#Tue Jul 24 08:17:27 CEST 2007
javac
=
javac
benchmark.drivers.dir
=
D
\:
/data/java
benchmark.drivers.dir
=
C
\:
/data/java
path.servlet.jar
=
C
\:
/data/classpath/servlet-api.jar
version.name.maven
=
1.0.20070712
jdk
=
1.4
h2/build.xml
浏览文件 @
35e27cd5
...
...
@@ -113,6 +113,7 @@
<copy
todir=
"bin"
overwrite=
"true"
>
<fileset
dir=
"src/main"
includes=
"META-INF/**/*"
/>
<fileset
dir=
"src/main"
includes=
"**/*.png"
/>
<fileset
dir=
"src/main"
includes=
"**/*.sql"
/>
<fileset
dir=
"src/installer"
includes=
"*.bat"
/>
<fileset
dir=
"src/test"
includes=
"**/*.txt"
/>
<fileset
dir=
"src/test"
includes=
"**/*.properties"
/>
...
...
h2/src/docsrc/html/advanced.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Advanced Topics
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
@@ -189,30 +191,30 @@ databases will be on different servers.
Each directory will simulate a directory on a computer.
</li><li>
Start a TCP server pointing to the first directory.
You can do this using the command line:
<
/li><
pre>
<pre>
java org.h2.tools.Server
-tcp -tcpPort 9101
-baseDir server1
</pre>
<li>
Start a second TCP server pointing to the second directory.
<
/li><
li>
Start a second TCP server pointing to the second directory.
This will simulate a server running on a second (redundant) computer.
You can do this using the command line:
<
/li><
pre>
<pre>
java org.h2.tools.Server
-tcp -tcpPort 9102
-baseDir server2
</pre>
<li>
Use the CreateCluster tool to initialize clustering.
<
/li><
li>
Use the CreateCluster tool to initialize clustering.
This will automatically create a new, empty database if it does not exist.
Run the tool on the command line:
<
/li><
pre>
<pre>
java org.h2.tools.CreateCluster
-urlSource jdbc:h2:tcp://localhost:9101/test
-urlTarget jdbc:h2:tcp://localhost:9102/test
-user sa
-serverlist localhost:9101,localhost:9102
</pre>
<li>
You can now connect to the databases using
<
/li><
li>
You can now connect to the databases using
an application or the H2 Console using the JDBC URL
jdbc:h2:tcp://localhost:9101,localhost:9102/test
</li><li>
If you stop a server (by killing the process),
...
...
@@ -239,16 +241,16 @@ The two phase commit protocol is supported. 2-phase-commit works as follows:
<li>
Autocommit needs to be switched off
</li><li>
A transaction is started, for example by inserting a row
</li><li>
The transaction is marked 'prepared' by executing the SQL statement
<
/li><
code>
PREPARE COMMIT transactionName
</code>
<li>
The transaction can now be committed or rolled back
<code>
PREPARE COMMIT transactionName
</code>
<
/li><
li>
The transaction can now be committed or rolled back
</li><li>
If a problem occurs before the transaction was successfully committed or rolled back
(for example because a network problem occurred), the transaction is in the state 'in-doubt'
</li><li>
When re-connecting to the database, the in-doubt transactions can be listed
with
<
/li><
code>
SELECT * FROM INFORMATION_SCHEMA.IN_DOUBT
</code>
<li>
Each transaction in this list must now be committed or rolled back by executing
<
/li><
code>
COMMIT TRANSACTION transactionName
</code>
or
with
<code>
SELECT * FROM INFORMATION_SCHEMA.IN_DOUBT
</code>
<
/li><
li>
Each transaction in this list must now be committed or rolled back by executing
<code>
COMMIT TRANSACTION transactionName
</code>
or
<code>
ROLLBACK TRANSACTION transactionName
</code>
<li>
The database needs to be closed and re-opened to apply the changes
<
/li><
li>
The database needs to be closed and re-opened to apply the changes
</li></ul>
<br
/><a
name=
"compatibility"
></a>
...
...
h2/src/docsrc/html/build.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Build
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
h2/src/docsrc/html/download.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). -->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
H2 Database Engine
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<link
rel=
"alternate"
type=
"application/atom+xml"
title=
"H2 Newsfeed"
href=
"http://www.h2database.com/html/newsfeed-atom.xml"
/>
...
...
h2/src/docsrc/html/faq.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Frequently Asked Questions
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
h2/src/docsrc/html/features.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Features
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
h2/src/docsrc/html/history.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
History
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
@@ -37,7 +39,13 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>
Version 1.0 (Current)
</h3>
<h3>
Version 1.0 / 2007-TODO
</h3><ul>
<li>
The old view implementation has been removed.
<li>
The default value for h2.defaultMaxMemoryUndo is now 50000.
This avoids out of memory problems when using very large transactions,
however large transactions are slower because they are buffered to disk.
To disable, use -Dh2.defaultMaxMemoryUndo=2000000000.
</li><li>
Support for regular expression function REGEXP_REPLACE(expression, regex, replacement)
and regular expression LIKE: expression REGEXP matchExpression. However, indexes are not yet used.
</li><li>
The old view implementation has been removed.
</li><li>
The SysTray tool has been removed, because JDK 1.6 has native support for system tray icons.
Use the Console tool (org.h2.tools.Console) automatically installs a system tray icon if JDK 1.6 is used.
</li><li>
H2 Console: In the last release, the shutdown button did not work. Fixed.
...
...
@@ -1058,8 +1066,6 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>
Server protocol: use challenge response authentication, but client sends hash(user+password) encrypted with response
</li><li>
Support EXEC[UTE] (doesn't return a result set, compatible to MS SQL Server)
</li><li>
GROUP BY and DISTINCT: support large groups (buffer to disk), do not keep large sets in memory
</li><li>
Regular expression replaceAll: REGEXP_REPLACE(expression, regex, replacement)
</li><li>
Regular expression LIKE: expression REGEXP matchExpression
</li><li>
Support native XML data type
</li><li>
Support triggers with a string property or option: SpringTrigger, OSGITrigger
</li><li>
Clustering: adding a node should be very fast and without interrupting clients (very short lock)
...
...
@@ -1069,6 +1075,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>
Automatic conversion from WHERE X>10 AND X>20 to X>20
</li><li>
Time based cache writing (one second after writing the log)
</li><li>
Write a H2 driver for http://db.apache.org/ddlutils/
</li><li>
Index usage for REGEXP LIKE.
</li></ul>
<h3>
Not Planned
</h3>
...
...
h2/src/docsrc/html/installation.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Installation
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
h2/src/docsrc/html/main.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
H2 Database Engine
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
h2/src/docsrc/html/mainWeb_text_.html
浏览文件 @
35e27cd5
...
...
@@ -117,7 +117,7 @@ Welcome to H2, the free SQL database. The main feature of H2 are:
to get informed about new releases.
Your email address is only used in this context.
<br
/>
If you don't want a Google account, there is a manually maintained list as well:
<br
/>
Email:
<input
type=
"
email
"
name=
"email"
size=
"30"
/>
Email:
<input
type=
"
text
"
name=
"email"
size=
"30"
/>
<input
type=
"hidden"
name=
"text"
value=
"subscribe"
/>
<input
type=
"submit"
value=
"Submit"
/>
</form>
...
...
@@ -157,7 +157,7 @@ Welcome to H2, the free SQL database. The main feature of H2 are:
<form
method=
"post"
action=
"php/sendMail.php"
>
<p>
Email (optional):
<br
/>
<input
name=
"email"
size=
"73"
type=
"
email
"
/>
<input
name=
"email"
size=
"73"
type=
"
text
"
/>
</p>
Message:
<br
/>
<textarea
name=
"text"
cols=
"70"
rows=
"5"
></textarea>
...
...
h2/src/docsrc/html/performance.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Performance
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
h2/src/docsrc/html/quickstartText.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Quickstart
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
@@ -25,7 +27,7 @@ This database can be used in embedded mode, or in server mode. To use it in embe
<li>
Add
<code>
h2.jar
</code>
to the classpath
</li><li>
Use the JDBC driver class:
<code>
org.h2.Driver
</code>
</li><li>
The database URL
<code>
jdbc:h2:~/test
</code>
opens the database 'test' in your user home directory
</ul>
</
li></
ul>
<br
/><a
name=
"h2_console"
></a>
<h2>
The H2 Console Application
</h2>
...
...
@@ -49,7 +51,7 @@ Click <span class="button">Start</span>,
<img
class=
"screenshot"
src=
"quickstart-1.png"
alt=
"screenshot: start H2 Console"
/><br
/>
A new console window appears:
<br
/>
<img
class=
"screenshot"
src=
"quickstart-2.png"
alt=
"screenshot: H2 Running"
/><br
/>
Also, a new browser page should open with the URL
<a
href=
"http://localhost:8082"
target=
"_blank"
>
http://localhost:8082
</a>
.
Also, a new browser page should open with the URL
http://localhost:8082
.
You may get a security warning from the firewall. If you don't want other computers in the network to access the database
on your machine, you can let the firewall block these connections. Only local connections are required at this time.
...
...
h2/src/docsrc/html/tutorial.html
浏览文件 @
35e27cd5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html><head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Tutorial
</title><link
rel=
"stylesheet"
type=
"text/css"
href=
"stylesheet.css"
/>
<script
type=
"text/javascript"
src=
"navigation.js"
></script>
...
...
@@ -29,6 +31,8 @@ Tutorial
Upgrade, Backup, and Restore
</a><br
/>
<a
href=
"#open_office"
>
Using OpenOffice Base
</a><br
/>
<a
href=
"#web_start"
>
Java Web Start / JNLP
</a><br
/>
<br
/><a
name=
"tutorial_starting_h2_console"
></a>
<h2>
Starting and Using the H2 Console
</h2>
...
...
@@ -52,8 +56,7 @@ Depending on your platform and environment, there are multiple ways to start the
<img
src=
"h2.png"
alt=
"[H2 icon]"
/><br
/>
If you don't get the window and the system tray icon,
then maybe Java is not installed correctly (in this case, try another way to start the application).
A browser window should open
and point to the Login page (URL:
<a
href=
"http://localhost:8082"
target=
"_blank"
>
http://localhost:8082
</a>
).
A browser window should open and point to the Login page http://localhost:8082).
</td>
</tr>
<tr>
...
...
@@ -62,7 +65,7 @@ Depending on your platform and environment, there are multiple ways to start the
Open a file browser, navigate to h2/bin, and double click on h2.bat.
<br
/>
A console window appears. If there is a problem, you will see an error message
in this window. A browser window will open and point to the Login page
(URL:
<a
href=
"http://localhost:8082"
target=
"_blank"
>
http://localhost:8082
</a>
).
(URL:
http://localhost:8082
).
</td>
</tr>
<tr>
...
...
@@ -421,4 +424,19 @@ The steps to connect to a H2 database are:
</li></ul>
Now you can access the database stored in the directory C:/temp.
<br
/><a
name=
"web_start"
></a>
<h2>
Java Web Start / JNLP
</h2>
When using Java Web Start / JNLP (Java Network Launch Protocol), permissions tags must be set in the .jnlp file,
and the application .jar file must be signed. Otherwise, when trying to write to the file system, the following
exception will occur: java.security.AccessControlException: access denied (java.io.FilePermission ... read).
Example permission tags:
<pre>
<
security>
<
all-permissions/>
<
/security>
</pre>
</div></td></tr></table></body></html>
\ No newline at end of file
h2/src/main/org/h2/Driver.java
浏览文件 @
35e27cd5
...
...
@@ -103,8 +103,8 @@ public class Driver implements java.sql.Driver {
/**
* INTERNAL
*/
public
static
void
load
()
{
// does nothing, but calling it loads the class
public
static
Driver
load
()
{
return
instance
;
}
}
h2/src/main/org/h2/command/Parser.java
浏览文件 @
35e27cd5
差异被折叠。
点击展开。
h2/src/main/org/h2/command/dml/TransactionCommand.java
浏览文件 @
35e27cd5
...
...
@@ -30,6 +30,7 @@ public class TransactionCommand extends Prepared {
public
static
final
int
ROLLBACK_TRANSACTION
=
11
;
public
static
final
int
SHUTDOWN
=
12
;
public
static
final
int
SHUTDOWN_IMMEDIATELY
=
13
;
public
static
final
int
BEGIN
=
14
;
private
int
type
;
private
String
savepointName
;
...
...
@@ -52,6 +53,9 @@ public class TransactionCommand extends Prepared {
case
AUTOCOMMIT_FALSE:
session
.
setAutoCommit
(
false
);
break
;
case
BEGIN:
session
.
begin
();
break
;
case
COMMIT:
session
.
commit
(
false
);
break
;
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
35e27cd5
...
...
@@ -250,7 +250,7 @@ public class Constants {
public
static
final
int
CACHE_SIZE_INDEX_SHIFT
=
getIntSetting
(
"h2.cacheSizeIndexShift"
,
3
);
public
static
final
int
CACHE_SIZE_INDEX_DEFAULT
=
CACHE_SIZE_DEFAULT
>>
CACHE_SIZE_INDEX_SHIFT
;
public
static
String
BASE_DIR
=
getStringSetting
(
"h2.baseDir"
,
null
);
public
static
final
int
DEFAULT_MAX_MEMORY_UNDO
=
getIntSetting
(
"h2.defaultMaxMemoryUndo"
,
Integer
.
MAX_VALUE
);
public
static
final
int
DEFAULT_MAX_MEMORY_UNDO
=
getIntSetting
(
"h2.defaultMaxMemoryUndo"
,
50000
);
public
static
final
boolean
OPTIMIZE_NOT
=
getBooleanSetting
(
"h2.optimizeNot"
,
true
);
public
static
final
boolean
OPTIMIZE_2_EQUALS
=
getBooleanSetting
(
"h2.optimizeTwoEquals"
,
true
);
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
35e27cd5
...
...
@@ -21,6 +21,7 @@ public class Mode {
public
boolean
lowerCaseIdentifiers
;
public
boolean
indexDefinitionInCreateTable
;
public
boolean
systemColumns
;
public
boolean
squareBracketQuotedNames
;
private
static
final
HashMap
MODES
=
new
HashMap
();
...
...
@@ -56,6 +57,11 @@ public class Mode {
mode
.
nullConcatIsNull
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"MSSQLServer"
);
mode
.
squareBracketQuotedNames
=
true
;
add
(
mode
);
}
private
static
void
add
(
Mode
mode
)
{
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
35e27cd5
...
...
@@ -65,6 +65,7 @@ public class Session implements SessionInterface {
private
static
int
nextSerialId
;
private
int
serialId
=
nextSerialId
++;
private
boolean
undoLogEnabled
=
true
;
private
boolean
autoCommitAtTransactionEnd
;
public
Session
()
{
}
...
...
@@ -191,6 +192,10 @@ public class Session implements SessionInterface {
if
(!
ddl
)
{
// do not clean the temp tables if the last command was a create/drop
cleanTempTables
(
false
);
if
(
autoCommitAtTransactionEnd
)
{
autoCommit
=
true
;
autoCommitAtTransactionEnd
=
false
;
}
}
if
(
unlinkSet
!=
null
&&
unlinkSet
.
size
()
>
0
)
{
// need to flush the log file, because we can't unlink lobs if the commit record is not written
...
...
@@ -216,6 +221,10 @@ public class Session implements SessionInterface {
}
cleanTempTables
(
false
);
unlockAll
();
if
(
autoCommitAtTransactionEnd
)
{
autoCommit
=
true
;
autoCommitAtTransactionEnd
=
false
;
}
}
public
void
rollbackTo
(
int
index
)
throws
SQLException
{
...
...
@@ -531,5 +540,10 @@ public class Session implements SessionInterface {
public
boolean
getUndoLogEnabled
()
{
return
undoLogEnabled
;
}
public
void
begin
()
{
autoCommitAtTransactionEnd
=
true
;
autoCommit
=
false
;
}
}
h2/src/main/org/h2/expression/CompareLike.java
浏览文件 @
35e27cd5
...
...
@@ -5,6 +5,7 @@
package
org
.
h2
.
expression
;
import
java.sql.SQLException
;
import
java.util.regex.Pattern
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Session
;
...
...
@@ -26,6 +27,7 @@ import org.h2.value.ValueString;
public
class
CompareLike
extends
Condition
{
private
final
CompareMode
compareMode
;
private
final
boolean
regexp
;
private
Expression
left
;
private
Expression
right
;
private
Expression
escape
;
...
...
@@ -33,22 +35,29 @@ public class CompareLike extends Condition {
private
boolean
isInit
;
private
char
[]
pattern
;
private
String
patternString
;
private
Pattern
patternRegexp
;
private
int
[]
types
;
private
int
patternLength
;
private
static
final
int
MATCH
=
0
,
ONE
=
1
,
ANY
=
2
;
private
boolean
ignoreCase
;
public
CompareLike
(
CompareMode
compareMode
,
Expression
left
,
Expression
right
,
Expression
escape
)
{
public
CompareLike
(
CompareMode
compareMode
,
Expression
left
,
Expression
right
,
Expression
escape
,
boolean
regexp
)
{
this
.
compareMode
=
compareMode
;
this
.
regexp
=
regexp
;
this
.
left
=
left
;
this
.
right
=
right
;
this
.
escape
=
escape
;
}
public
String
getSQL
()
{
String
sql
=
left
.
getSQL
()
+
" LIKE "
+
right
.
getSQL
();
if
(
escape
!=
null
)
{
sql
+=
" ESCAPE "
+
escape
.
getSQL
();
String
sql
;
if
(
regexp
)
{
sql
=
left
.
getSQL
()
+
" REGEXP "
+
right
.
getSQL
();
}
else
{
sql
=
left
.
getSQL
()
+
" LIKE "
+
right
.
getSQL
();
if
(
escape
!=
null
)
{
sql
+=
" ESCAPE "
+
escape
.
getSQL
();
}
}
return
"("
+
sql
+
")"
;
}
...
...
@@ -104,6 +113,9 @@ public class CompareLike extends Condition {
}
public
void
createIndexConditions
(
TableFilter
filter
)
throws
SQLException
{
if
(
regexp
)
{
return
;
}
Session
session
=
filter
.
getSession
();
if
(!(
left
instanceof
ExpressionColumn
))
{
return
;
...
...
@@ -184,7 +196,12 @@ public class CompareLike extends Condition {
initPattern
(
pattern
,
getEscapeChar
(
e
));
}
String
value
=
l
.
getString
();
boolean
result
=
compareAt
(
value
,
0
,
0
,
value
.
length
());
boolean
result
;
if
(
regexp
)
{
result
=
patternRegexp
.
matcher
(
value
).
matches
();
}
else
{
result
=
compareAt
(
value
,
0
,
0
,
value
.
length
());
}
return
ValueBoolean
.
get
(
result
);
}
...
...
@@ -231,6 +248,15 @@ public class CompareLike extends Condition {
}
private
void
initPattern
(
String
p
,
char
escape
)
throws
SQLException
{
if
(
regexp
)
{
patternString
=
p
;
if
(
ignoreCase
)
{
patternRegexp
=
Pattern
.
compile
(
p
,
Pattern
.
CASE_INSENSITIVE
);
}
else
{
patternRegexp
=
Pattern
.
compile
(
p
);
}
return
;
}
patternLength
=
0
;
if
(
p
==
null
)
{
types
=
null
;
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
35e27cd5
...
...
@@ -78,7 +78,7 @@ public class Function extends Expression implements FunctionCall {
SUBSTRING
=
73
,
UCASE
=
74
,
LOWER
=
75
,
UPPER
=
76
,
POSITION
=
77
,
TRIM
=
78
,
STRINGENCODE
=
79
,
STRINGDECODE
=
80
,
STRINGTOUTF8
=
81
,
UTF8TOSTRING
=
82
,
XMLATTR
=
83
,
XMLNODE
=
84
,
XMLCOMMENT
=
85
,
XMLCDATA
=
86
,
XMLSTARTDOC
=
87
,
XMLTEXT
=
88
;
XMLTEXT
=
88
,
REGEXP_REPLACE
=
89
;
public
static
final
int
CURDATE
=
100
,
CURTIME
=
101
,
DATEADD
=
102
,
DATEDIFF
=
103
,
DAYNAME
=
104
,
DAYOFMONTH
=
105
,
DAYOFWEEK
=
106
,
DAYOFYEAR
=
107
,
...
...
@@ -228,6 +228,7 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"XMLCDATA"
,
XMLCDATA
,
1
,
Value
.
STRING
);
addFunction
(
"XMLSTARTDOC"
,
XMLSTARTDOC
,
0
,
Value
.
STRING
);
addFunction
(
"XMLTEXT"
,
XMLTEXT
,
1
,
Value
.
STRING
);
addFunction
(
"REGEXP_REPLACE"
,
REGEXP_REPLACE
,
3
,
Value
.
STRING
);
// date
addFunctionNotConst
(
"CURRENT_DATE"
,
CURRENT_DATE
,
0
,
Value
.
DATE
);
...
...
@@ -678,6 +679,8 @@ public class Function extends Expression implements FunctionCall {
return
ValueString
.
get
(
StringUtils
.
xmlStartDoc
());
case
XMLTEXT:
return
ValueString
.
get
(
StringUtils
.
xmlText
(
v0
.
getString
()));
case
REGEXP_REPLACE:
return
ValueString
.
get
(
v0
.
getString
().
replaceAll
(
v1
.
getString
(),
v2
.
getString
()));
// date
case
DATEADD:
return
ValueTimestamp
.
getNoCopy
(
dateadd
(
v0
.
getString
(),
v1
.
getInt
(),
v2
.
getTimestampNoCopy
()));
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
35e27cd5
...
...
@@ -1177,11 +1177,15 @@ compare { {{ALL|ANY|SOME}(select)} | operand }
| BETWEEN operand AND operand
| IN ({select | expression[,...]})
| [NOT] LIKE operand [ESCAPE string]
| [NOT] REGEXP operand
","
The right hand side of a condition.
The right hand side of a condition.
When comparing with LIKE, the wildcards characters are _ (any one character) and % (any characters).
When comparing with REGEXP, regular expression matching is used. See Java String.matches for details.
","
LIKE 'Jo%'
"
"Other Grammar","Compare","
= | < | > | <> | <= | >= | !=
","
...
...
@@ -2160,6 +2164,16 @@ It is possible to remove other characters as well.
","
TRIM(BOTH '_' FROM NAME)
"
"Functions (String)","REGEXP_REPLACE","
REGEXP_REPLACE(inputString, regexString, replacementString): string
","
Replaces each substring that matches a regular expression.
For details, see the Java String.replaceAll() method.
","
REGEXP_REPLACE('Hoohoho', 'o+', 'o')
"
"Functions (String)","REPEAT","
REPEAT(string, int): string
","
...
...
@@ -2167,6 +2181,7 @@ Returns a string repeated some number of times.
","
REPEAT(NAME || ' ', 10)
"
"Functions (String)","REPLACE","
REPLACE(string, searchString [, replacementString]): string
","
...
...
h2/src/main/org/h2/server/pg/PgServer.java
浏览文件 @
35e27cd5
...
...
@@ -26,7 +26,6 @@ import org.h2.util.NetUtils;
*/
public
class
PgServer
implements
Service
{
// public static final int DEFAULT_PORT = 5433; // also in the docs
public
static
final
int
DEFAULT_PORT
=
5435
;
// also in the docs
private
int
port
=
PgServer
.
DEFAULT_PORT
;
...
...
@@ -83,7 +82,10 @@ public class PgServer implements Service {
}
}
org
.
h2
.
Driver
.
load
();
url
=
"odbc://localhost:"
+
port
;
url
=
"pg://localhost:"
+
port
;
int
testing
;
// log = true;
}
public
String
getURL
()
{
...
...
@@ -219,7 +221,7 @@ public class PgServer implements Service {
case
8
:
return
"LATIN1"
;
}
return
"UTF8
"
;
return
code
<
40
?
"UTF8"
:
"
"
;
}
public
static
String
getVersion
()
{
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
35e27cd5
差异被折叠。
点击展开。
h2/src/main/org/h2/server/pg/pg_catalog.sql
浏览文件 @
35e27cd5
...
...
@@ -8,7 +8,7 @@ create schema pg_catalog;
set
search_path
=
PUBLIC
,
pg_catalog
;
create
table
pg_catalog
.
pg_roles
-- (oid, rolname, rolcreaterole, rolcreatedb)
create
view
pg_catalog
.
pg_roles
-- (oid, rolname, rolcreaterole, rolcreatedb)
as
select
id
oid
,
...
...
@@ -17,7 +17,7 @@ select
case
when
admin
then
't'
else
'f'
end
as
rolcreatedb
from
information_schema
.
users
;
create
table
pg_catalog
.
pg_namespace
-- (oid, nspname)
create
view
pg_catalog
.
pg_namespace
-- (oid, nspname)
as
select
id
oid
,
...
...
@@ -38,7 +38,8 @@ select
(
select
oid
from
pg_catalog
.
pg_namespace
where
nspname
=
'pg_catalog'
)
typnamespace
,
-
1
typlen
,
0
typbasetype
from
information_schema
.
type_info
;
from
information_schema
.
type_info
where
pos
=
0
;
insert
into
pg_catalog
.
pg_type
values
(
1111
,
...
...
@@ -48,7 +49,7 @@ insert into pg_catalog.pg_type values(
0
);
create
table
pg_catalog
.
pg_class
-- (oid, relname, relnamespace, relkind, relam, reltuples, relpages, relhasrules, relhasoids)
create
view
pg_catalog
.
pg_class
-- (oid, relname, relnamespace, relkind, relam, reltuples, relpages, relhasrules, relhasoids)
as
select
id
oid
,
...
...
@@ -74,15 +75,6 @@ select
false
relhasoids
from
information_schema
.
indexes
;
create
table
pg_catalog
.
pg_description
-- (objoid, objsubid, classoid, description)
as
select
id
objoid
,
0
objsubid
,
-
1
classoid
,
cast
(
''
as
varchar_ignorecase
)
description
from
information_schema
.
tables
where
1
=
0
;
create
table
pg_catalog
.
pg_proc
(
oid
int
,
proname
varchar_ignorecase
...
...
@@ -100,7 +92,7 @@ create table pg_catalog.pg_trigger(
tgrelid
int
);
create
table
pg_catalog
.
pg_attrdef
-- (oid, adsrc, adrelid, adnum)
create
view
pg_catalog
.
pg_attrdef
-- (oid, adsrc, adrelid, adnum)
as
select
id
oid
,
...
...
@@ -109,7 +101,7 @@ select
0
adnum
from
information_schema
.
tables
where
1
=
0
;
create
table
pg_catalog
.
pg_attribute
-- (oid, attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, attisdropped, atthasdef)
create
view
pg_catalog
.
pg_attribute
-- (oid, attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, attisdropped, atthasdef)
as
select
t
.
id
*
10000
+
c
.
ordinal_position
oid
,
...
...
@@ -143,7 +135,7 @@ and t.table_schema = i.table_schema
and
t
.
table_name
=
c
.
table_name
and
t
.
table_schema
=
c
.
table_schema
;
create
table
pg_catalog
.
pg_index
-- (oid, indexrelid, indrelid, indisclustered, indisunique, indisprimary, indexprs, indkey)
create
view
pg_catalog
.
pg_index
-- (oid, indexrelid, indrelid, indisclustered, indisunique, indisprimary, indexprs, indkey)
as
select
i
.
id
oid
,
...
...
@@ -237,13 +229,9 @@ insert into pg_catalog.pg_settings values
(
1
,
'stats_start_collector'
,
'on'
),
(
2
,
'stats_row_level'
,
'on'
);
create
table
pg_catalog
.
pg_user
(
oid
int
,
usename
varchar_ignorecase
,
usecreatedb
boolean
,
usesuper
boolean
);
insert
into
pg_catalog
.
pg_user
select
create
view
pg_catalog
.
pg_user
-- oid, usename, usecreatedb, usesuper
as
select
id
oid
,
cast
(
name
as
varchar_ignorecase
)
usename
,
true
usecreatedb
,
...
...
@@ -269,36 +257,19 @@ create table pg_catalog.pg_am(oid int, amname varchar_ignorecase);
insert
into
pg_catalog
.
pg_am
values
(
0
,
'btree'
);
insert
into
pg_catalog
.
pg_am
values
(
1
,
'hash'
);
SELECT
NULL
AS
TABLE_CAT
,
n
.
nspname
AS
TABLE_SCHEM
,
ct
.
relname
AS
TABLE_NAME
,
NOT
i
.
indisunique
AS
NON_UNIQUE
,
NULL
AS
INDEX_QUALIFIER
,
ci
.
relname
AS
INDEX_NAME
,
CASE
i
.
indisclustered
WHEN
true
THEN
1
ELSE
CASE
am
.
amname
WHEN
'hash'
THEN
2
ELSE
3
END
END
AS
TYPE
,
a
.
attnum
AS
ORDINAL_POSITION
,
CASE
i
.
indexprs
WHEN
null
THEN
a
.
attname
ELSE
pg_get_indexdef
(
ci
.
oid
,
a
.
attnum
,
false
)
END
AS
COLUMN_NAME
,
NULL
AS
ASC_OR_DESC
,
ci
.
reltuples
AS
CARDINALITY
,
ci
.
relpages
AS
PAGES
,
NULL
AS
FILTER_CONDITION
FROM
pg_catalog
.
pg_namespace
n
,
pg_catalog
.
pg_class
ct
,
pg_catalog
.
pg_class
ci
,
pg_catalog
.
pg_attribute
a
,
pg_catalog
.
pg_am
am
,
pg_catalog
.
pg_index
i
WHERE
ct
.
oid
=
i
.
indrelid
AND
ci
.
oid
=
i
.
indexrelid
AND
a
.
attrelid
=
ci
.
oid
AND
ci
.
relam
=
am
.
oid
AND
n
.
oid
=
ct
.
relnamespace
AND
n
.
nspname
=
'PUBLIC'
AND
ct
.
relname
=
'TEST'
ORDER
BY
NON_UNIQUE
,
TYPE
,
INDEX_NAME
,
ORDINAL_POSITION
;
create
table
pg_catalog
.
pg_description
-- (objoid, objsubid, classoid, description)
as
select
oid
objoid
,
0
objsubid
,
-
1
classoid
,
cast
(
datname
as
varchar_ignorecase
)
description
from
pg_catalog
.
pg_database
;
create
table
pg_catalog
.
pg_group
-- oid, groname
as
select
0
oid
,
cast
(
''
as
varchar_ignorecase
)
groname
from
pg_catalog
.
pg_database
where
1
=
0
;
h2/src/main/org/h2/tools/Console.java
浏览文件 @
35e27cd5
...
...
@@ -64,7 +64,7 @@ public class Console implements ActionListener, MouseListener {
System
.
out
.
println
(
web
.
getStatus
());
}
}
Server
tcp
=
null
,
odbc
=
null
;
Server
tcp
=
null
,
odbc
=
null
,
pg
=
null
;
try
{
tcp
=
Server
.
createTcpServer
(
args
);
tcp
.
start
();
...
...
@@ -85,6 +85,16 @@ public class Console implements ActionListener, MouseListener {
System
.
out
.
println
(
odbc
.
getStatus
());
}
}
try
{
pg
=
Server
.
createPgServer
(
args
);
pg
.
start
();
}
catch
(
SQLException
e
)
{
if
(
pg
==
null
)
{
e
.
printStackTrace
();
}
else
{
System
.
out
.
println
(
pg
.
getStatus
());
}
}
if
(!
GraphicsEnvironment
.
isHeadless
())
{
font
=
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
11
);
try
{
...
...
h2/src/main/org/h2/tools/Server.java
浏览文件 @
35e27cd5
...
...
@@ -16,6 +16,7 @@ import org.h2.server.OdbcServer;
import
org.h2.server.Service
;
import
org.h2.server.TcpServer
;
import
org.h2.server.ftp.FtpServer
;
import
org.h2.server.pg.PgServer
;
import
org.h2.server.web.WebServer
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
...
...
@@ -51,6 +52,10 @@ public class Server implements Runnable {
System
.
out
.
println
(
"-odbcPort <port> (default: "
+
OdbcServer
.
DEFAULT_PORT
+
")"
);
System
.
out
.
println
(
"-odbcAllowOthers [true|false]"
);
System
.
out
.
println
(
"-pg (start the PG Server)"
);
System
.
out
.
println
(
"-pgPort <port> (default: "
+
PgServer
.
DEFAULT_PORT
+
")"
);
System
.
out
.
println
(
"-pgAllowOthers [true|false]"
);
System
.
out
.
println
(
"-ftp (start the FTP Server)"
);
System
.
out
.
println
(
"-ftpPort <port> (default: "
+
Constants
.
DEFAULT_FTP_PORT
+
")"
);
System
.
out
.
println
(
"-ftpDir <directory> (default: "
+
FtpServer
.
DEFAULT_ROOT
+
", use jdbc:... to access a database)"
);
...
...
@@ -78,6 +83,7 @@ public class Server implements Runnable {
* </li><li>-tcp (start the TCP Server)
* </li><li>-tcpShutdown {url} (shutdown the running TCP Server, URL example: tcp://localhost:9094)
* </li><li>-odbc (start the ODBC Server)
* </li><li>-pg (start the PG Server)
* </li><li>-browser (start a browser and open a page to connect to the Web Server)
* </li><li>-log [true|false] (enable or disable logging)
* </li><li>-baseDir {directory} (sets the base directory for database files; not for H2 Console)
...
...
@@ -94,6 +100,8 @@ public class Server implements Runnable {
* </li><li>-tcpAllowOthers [true|false] (enable/disable remote connections)
* </li><li>-tcpPassword {password} (the password for shutting down a TCP Server)
* </li><li>-tcpShutdownForce [true|false] (don't wait for other connections to close)
* </li><li>-pgPort {port} (the port of PG Server, default: 5435)
* </li><li>-pgAllowOthers [true|false] (enable/disable remote connections)
* </li><li>-odbcPort {port} (the port of ODBC Server, default: 9083)
* </li><li>-odbcAllowOthers [true|false] (enable/disable remote connections)
* </li><li>-ftpPort {port}
...
...
@@ -114,7 +122,7 @@ public class Server implements Runnable {
}
private
int
run
(
String
[]
args
)
throws
SQLException
{
boolean
tcpStart
=
false
,
odbcStart
=
false
,
webStart
=
false
,
ftpStart
=
false
;
boolean
tcpStart
=
false
,
odbcStart
=
false
,
pgStart
=
false
,
webStart
=
false
,
ftpStart
=
false
;
boolean
browserStart
=
false
;
boolean
tcpShutdown
=
false
,
tcpShutdownForce
=
false
;
String
tcpPassword
=
""
;
...
...
@@ -134,6 +142,9 @@ public class Server implements Runnable {
}
else
if
(
a
.
equals
(
"-tcp"
))
{
startDefaultServers
=
false
;
tcpStart
=
true
;
}
else
if
(
a
.
equals
(
"-pg"
))
{
startDefaultServers
=
false
;
pgStart
=
true
;
}
else
if
(
a
.
equals
(
"-ftp"
))
{
startDefaultServers
=
false
;
ftpStart
=
true
;
...
...
@@ -153,6 +164,7 @@ public class Server implements Runnable {
int
exitCode
=
0
;
if
(
startDefaultServers
)
{
tcpStart
=
true
;
pgStart
=
true
;
odbcStart
=
true
;
webStart
=
true
;
browserStart
=
true
;
...
...
@@ -173,6 +185,17 @@ public class Server implements Runnable {
}
System
.
out
.
println
(
tcp
.
getStatus
());
}
if
(
pgStart
)
{
Server
pg
=
createPgServer
(
args
);
try
{
pg
.
start
();
}
catch
(
SQLException
e
)
{
// ignore (status is displayed)
e
.
printStackTrace
();
exitCode
=
EXIT_ERROR
;
}
System
.
out
.
println
(
pg
.
getStatus
());
}
if
(
odbcStart
)
{
Server
odbc
=
createOdbcServer
(
args
);
try
{
...
...
@@ -327,6 +350,15 @@ public class Server implements Runnable {
return
new
Server
(
"H2 ODBC Server"
,
new
OdbcServer
(),
args
);
}
/**
* Create a new PG server, but does not start it yet.
* @param args
* @return the server
*/
public
static
Server
createPgServer
(
String
[]
args
)
throws
SQLException
{
return
new
Server
(
"H2 PG Server"
,
new
PgServer
(),
args
);
}
/**
* Tries to start the server.
* @return the server if successful
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
35e27cd5
...
...
@@ -102,7 +102,8 @@ public class DateTimeUtils {
return
x
==
null
?
null
:
new
Time
(
getLocalTime
(
x
,
calendar
));
}
public
static
java
.
util
.
Date
parseDateTime
(
String
s
,
int
type
,
int
errorCode
)
throws
SQLException
{
public
static
java
.
util
.
Date
parseDateTime
(
String
original
,
int
type
,
int
errorCode
)
throws
SQLException
{
String
s
=
original
;
if
(
s
==
null
)
{
return
null
;
}
...
...
@@ -159,7 +160,7 @@ public class DateTimeUtils {
if
(!
tz
.
getID
().
equals
(
tzName
))
{
throw
Message
.
getSQLException
(
errorCode
,
s
+
" "
+
tz
.
getID
()
+
"/"
+
tzName
);
}
s
=
s
.
substring
(
0
,
timezoneStart
);
s
=
s
.
substring
(
0
,
timezoneStart
)
.
trim
()
;
}
}
...
...
@@ -210,7 +211,7 @@ public class DateTimeUtils {
throw
Message
.
getInternalError
(
"type:"
+
type
);
}
}
catch
(
IllegalArgumentException
e
)
{
throw
Message
.
getSQLException
(
errorCode
,
new
String
[]{
s
},
e
);
throw
Message
.
getSQLException
(
errorCode
,
new
String
[]{
original
},
e
);
}
}
...
...
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
浏览文件 @
35e27cd5
...
...
@@ -6,6 +6,7 @@ package org.h2.value;
import
org.h2.engine.Constants
;
import
org.h2.util.StringCache
;
import
org.h2.util.StringUtils
;
public
class
ValueStringIgnoreCase
extends
ValueStringBase
{
...
...
@@ -36,6 +37,10 @@ public class ValueStringIgnoreCase extends ValueStringBase {
}
return
hash
;
}
public
String
getSQL
()
{
return
"CAST("
+
StringUtils
.
quoteStringSQL
(
value
)
+
" AS VARCHAR_IGNORECASE)"
;
}
public
static
ValueStringIgnoreCase
get
(
String
s
)
{
if
(
s
.
length
()
==
0
)
{
...
...
h2/src/test/org/h2/samples/MixedMode.java
0 → 100644
浏览文件 @
35e27cd5
package
org
.
h2
.
samples
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.tools.Server
;
public
class
MixedMode
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// start the server, allows to access the database remotly
Server
server
=
Server
.
createTcpServer
(
new
String
[]{
"-tcpPort"
,
"9081"
});
server
.
start
();
System
.
out
.
println
(
"You can access the database remotely now, using the URL:"
);
System
.
out
.
println
(
"jdbc:h2:tcp://localhost:9081/~/test (user: sa, password: sa)"
);
// now use the database in your application in embedded mode
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"sa"
,
"sa"
);
// some simple 'business usage'
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE TIMER IF EXISTS"
);
stat
.
execute
(
"CREATE TABLE TIMER(ID INT PRIMARY KEY, TIME VARCHAR)"
);
System
.
out
.
println
(
"Execute this a few times: SELECT TIME FROM TIMER"
);
System
.
out
.
println
(
"To stop this application (and the server), run: DROP TABLE TIMER"
);
try
{
while
(
true
)
{
// runs forever, except if you drop the table remotely
stat
.
execute
(
"MERGE INTO TIMER VALUES(1, NOW())"
);
Thread
.
sleep
(
1000
);
}
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"Errror: "
+
e
.
toString
());
}
conn
.
close
();
// stop the server
server
.
stop
();
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
35e27cd5
...
...
@@ -94,13 +94,26 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
/*
SELECT db.oid, datname, spcname, datallowconn, datconfig, datacl, pg_encoding_to_char(encoding) AS serverencoding,
pg_get_userbyid(datdba) AS datowner,has_database_privilege(db.oid, 'CREATE') as cancreate
FROM pg_database db
LEFT OUTER JOIN pg_tablespace ta ON db.dattablespace=ta.OID
ORDER BY datname;
SELECT description FROM pg_description WHERE objoid=0;
test.properties
#size = 400
size = 100
cd C:\data\h2database\h2\bin
java -cp %H2DRIVERS% org.h2.test.bench.TestPerformance
jdbc:postgresql://localhost:5435/test
SELECT nspname AS TABLE_SCHEM FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND nspname !~ '^pg_temp_' ORDER BY TABLE_SCHEM;
PostgreSQL: ~/test doesn't work. maybe need mapping 'database name > database url' (in properties file?)
html-ja
change default:
SET MAX_LENGTH_INPLACE_LOB 1024
SET MAX_MEMORY_UNDO 50000
rename Performance > Comparison [/Compatibility]
move Comparison to Other Database Engines > Comparison
...
...
@@ -197,6 +210,13 @@ http://javolution.org/
http://joda-time.sourceforge.net/
http://ibatis.apache.org/
strict xhtml (license,...)
Document org.h2.samples.MixedMode
http://www.igniterealtime.org/projects/openfire/index.jsp
(fonts)
*/
/*
...
...
h2/src/test/org/h2/test/bench/BenchA.java
浏览文件 @
35e27cd5
...
...
@@ -56,7 +56,7 @@ public class BenchA implements Bench {
prep
=
db
.
prepare
(
"INSERT INTO BRANCHES(BID,BBALANCE,FILLER) VALUES(?,10000.00,'"
+
FILLER
+
"')"
);
for
(
int
i
=
0
;
i
<
branches
*
scale
;
i
++)
{
prep
.
setInt
(
1
,
i
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertBranches"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -66,7 +66,7 @@ public class BenchA implements Bench {
for
(
int
i
=
0
;
i
<
tellers
*
scale
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setInt
(
2
,
i
/
tellers
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertTellers"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -77,7 +77,7 @@ public class BenchA implements Bench {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setInt
(
2
,
i
/
accounts
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertAccounts"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -136,15 +136,15 @@ public class BenchA implements Bench {
updateAccount
.
setBigDecimal
(
1
,
delta
);
updateAccount
.
setInt
(
2
,
account
);
db
.
update
(
updateAccount
);
db
.
update
(
updateAccount
,
"updateAccount"
);
updateTeller
.
setBigDecimal
(
1
,
delta
);
updateTeller
.
setInt
(
2
,
teller
);
db
.
update
(
updateTeller
);
db
.
update
(
updateTeller
,
"updateTeller"
);
updateBranch
.
setBigDecimal
(
1
,
delta
);
updateBranch
.
setInt
(
2
,
branch
);
db
.
update
(
updateBranch
);
db
.
update
(
updateBranch
,
"updateBranch"
);
selectBalance
.
setInt
(
1
,
account
);
db
.
queryReadResult
(
selectBalance
);
...
...
@@ -157,7 +157,7 @@ public class BenchA implements Bench {
// insertHistory.setDate(5, new java.sql.Date(current));
insertHistory
.
setTimestamp
(
5
,
new
java
.
sql
.
Timestamp
(
current
));
insertHistory
.
setString
(
6
,
BenchA
.
FILLER
);
db
.
update
(
insertHistory
);
db
.
update
(
insertHistory
,
"insertHistory"
);
db
.
commit
();
}
...
...
h2/src/test/org/h2/test/bench/BenchB.java
浏览文件 @
35e27cd5
...
...
@@ -62,7 +62,7 @@ public class BenchB implements Bench, Runnable {
"INSERT INTO BRANCHES(BID, BBALANCE) VALUES(?, 0)"
);
for
(
int
i
=
0
;
i
<
branches
*
scale
;
i
++)
{
prep
.
setInt
(
1
,
i
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertBranches"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -73,7 +73,7 @@ public class BenchB implements Bench, Runnable {
for
(
int
i
=
0
;
i
<
tellers
*
scale
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setInt
(
2
,
i
/
tellers
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertTellers"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -85,7 +85,7 @@ public class BenchB implements Bench, Runnable {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setInt
(
2
,
i
/
accounts
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertAccounts"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
h2/src/test/org/h2/test/bench/BenchC.java
浏览文件 @
35e27cd5
...
...
@@ -163,8 +163,6 @@ public class BenchC implements Bench {
trace
(
"load done"
);
}
void
trace
(
String
s
)
{
action
=
s
;
}
...
...
@@ -190,7 +188,7 @@ public class BenchC implements Bench {
prep
.
setString
(
3
,
i_name
);
prep
.
setBigDecimal
(
4
,
i_price
);
prep
.
setString
(
5
,
i_data
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertItem"
);
trace
(
i_id
,
items
);
if
(
i_id
%
commitEvery
==
0
)
{
db
.
commit
();
...
...
@@ -222,7 +220,7 @@ public class BenchC implements Bench {
prep
.
setString
(
7
,
w_zip
);
prep
.
setBigDecimal
(
8
,
w_tax
);
prep
.
setBigDecimal
(
9
,
w_ytd
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertWarehouse"
);
loadStock
(
w_id
);
loadDistrict
(
w_id
);
if
(
w_id
%
commitEvery
==
0
)
{
...
...
@@ -310,7 +308,7 @@ public class BenchC implements Bench {
prepCustomer
.
setBigDecimal
(
19
,
c_ytd_payment
);
prepCustomer
.
setInt
(
20
,
c_payment_cnt
);
prepCustomer
.
setInt
(
21
,
c_delivery_cnt
);
db
.
update
(
prepCustomer
);
db
.
update
(
prepCustomer
,
"insertCustomer"
);
BigDecimal
h_amount
=
new
BigDecimal
(
"10.00"
);
String
h_data
=
random
.
getString
(
12
,
24
);
prepHistory
.
setInt
(
1
,
c_id
);
...
...
@@ -321,7 +319,7 @@ public class BenchC implements Bench {
prepHistory
.
setTimestamp
(
6
,
timestamp
);
prepHistory
.
setBigDecimal
(
7
,
h_amount
);
prepHistory
.
setString
(
8
,
h_data
);
db
.
update
(
prepHistory
);
db
.
update
(
prepHistory
,
"insertHistory"
);
}
}
...
...
@@ -370,9 +368,9 @@ public class BenchC implements Bench {
prepNewOrder
.
setInt
(
1
,
o_id
);
prepNewOrder
.
setInt
(
2
,
o_d_id
);
prepNewOrder
.
setInt
(
3
,
o_w_id
);
db
.
update
(
prepNewOrder
);
db
.
update
(
prepNewOrder
,
"newNewOrder"
);
}
db
.
update
(
prepOrder
);
db
.
update
(
prepOrder
,
"insertOrder"
);
for
(
int
ol
=
1
;
ol
<=
o_ol_cnt
;
ol
++)
{
int
ol_i_id
=
random
.
getInt
(
1
,
items
);
int
ol_supply_w_id
=
o_w_id
;
...
...
@@ -393,7 +391,7 @@ public class BenchC implements Bench {
prepLine
.
setInt
(
7
,
ol_quantity
);
prepLine
.
setBigDecimal
(
8
,
ol_amount
);
prepLine
.
setString
(
9
,
ol_dist_info
);
db
.
update
(
prepLine
);
db
.
update
(
prepLine
,
"insertOrderLine"
);
if
(
i
++%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -443,7 +441,7 @@ public class BenchC implements Bench {
prep
.
setInt
(
15
,
0
);
prep
.
setInt
(
16
,
0
);
prep
.
setInt
(
17
,
0
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertStock"
);
if
(
s_i_id
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -479,7 +477,7 @@ public class BenchC implements Bench {
prep
.
setBigDecimal
(
9
,
d_tax
);
prep
.
setBigDecimal
(
10
,
d_ytd
);
prep
.
setInt
(
11
,
d_next_o_id
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertDistrict"
);
trace
(
d_id
,
districtsPerWarehouse
);
}
}
...
...
h2/src/test/org/h2/test/bench/BenchCThread.java
浏览文件 @
35e27cd5
...
...
@@ -112,7 +112,7 @@ public class BenchCThread {
+
"WHERE D_ID=? AND D_W_ID=?"
);
prep
.
setInt
(
1
,
d_id
);
prep
.
setInt
(
2
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateDistrict"
);
prep
=
prepare
(
"SELECT D_NEXT_O_ID, D_TAX FROM DISTRICT "
+
"WHERE D_ID=? AND D_W_ID=?"
);
prep
.
setInt
(
1
,
d_id
);
...
...
@@ -203,7 +203,7 @@ public class BenchCThread {
prep
.
setInt
(
1
,
s_quantity
);
prep
.
setInt
(
2
,
ol_supply_w_id
);
prep
.
setInt
(
3
,
ol_i_id
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateStock"
);
BigDecimal
ol_amount
=
new
BigDecimal
(
ol_quantity
).
multiply
(
i_price
).
multiply
(
ONE
.
add
(
w_tax
).
add
(
d_tax
)).
multiply
(
ONE
.
subtract
(
c_discount
));
...
...
@@ -223,7 +223,7 @@ public class BenchCThread {
prep
.
setInt
(
7
,
ol_quantity
);
prep
.
setBigDecimal
(
8
,
ol_amount
);
prep
.
setString
(
9
,
ol_dist_info
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertOrderLine"
);
}
prep
=
prepare
(
"INSERT INTO ORDERS (O_ID, O_D_ID, O_W_ID, O_C_ID, "
+
"O_ENTRY_D, O_OL_CNT, O_ALL_LOCAL) "
...
...
@@ -235,13 +235,13 @@ public class BenchCThread {
prep
.
setTimestamp
(
5
,
datetime
);
prep
.
setInt
(
6
,
o_ol_cnt
);
prep
.
setInt
(
7
,
o_all_local
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertOrders"
);
prep
=
prepare
(
"INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) "
+
"VALUES (?, ?, ?)"
);
prep
.
setInt
(
1
,
o_id
);
prep
.
setInt
(
2
,
d_id
);
prep
.
setInt
(
3
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertNewOrder"
);
db
.
commit
();
}
...
...
@@ -279,11 +279,11 @@ public class BenchCThread {
prep
.
setBigDecimal
(
1
,
h_amount
);
prep
.
setInt
(
2
,
d_id
);
prep
.
setInt
(
3
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateDistrict"
);
prep
=
prepare
(
"UPDATE WAREHOUSE SET W_YTD=W_YTD+? WHERE W_ID=?"
);
prep
.
setBigDecimal
(
1
,
h_amount
);
prep
.
setInt
(
2
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateWarehouse"
);
prep
=
prepare
(
"SELECT W_STREET_1, W_STREET_2, W_CITY, W_STATE, W_ZIP, W_NAME "
+
"FROM WAREHOUSE WHERE W_ID=?"
);
prep
.
setInt
(
1
,
warehouseId
);
...
...
@@ -409,7 +409,7 @@ public class BenchCThread {
prep
.
setInt
(
3
,
c_id
);
prep
.
setInt
(
4
,
c_d_id
);
prep
.
setInt
(
5
,
c_w_id
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateCustomer"
);
}
else
{
prep
=
prepare
(
"UPDATE CUSTOMER SET C_BALANCE=? "
+
"WHERE C_ID=? AND C_D_ID=? AND C_W_ID=?"
);
...
...
@@ -417,7 +417,7 @@ public class BenchCThread {
prep
.
setInt
(
2
,
c_id
);
prep
.
setInt
(
3
,
c_d_id
);
prep
.
setInt
(
4
,
c_w_id
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateCustomer"
);
}
// MySQL bug?
// String h_data = w_name + " " + d_name;
...
...
@@ -433,7 +433,7 @@ public class BenchCThread {
prep
.
setTimestamp
(
6
,
datetime
);
prep
.
setBigDecimal
(
7
,
h_amount
);
prep
.
setString
(
8
,
h_data
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertHistory"
);
db
.
commit
();
}
...
...
@@ -453,7 +453,7 @@ public class BenchCThread {
ResultSet
rs
;
prep
=
prepare
(
"UPDATE DISTRICT SET D_NEXT_O_ID=-1 WHERE D_ID=-1"
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateDistrict"
);
if
(
byName
)
{
prep
=
prepare
(
"SELECT COUNT(C_ID) FROM CUSTOMER "
+
"WHERE C_LAST=? AND C_D_ID=? AND C_W_ID=?"
);
...
...
@@ -552,7 +552,7 @@ public class BenchCThread {
ResultSet
rs
;
prep
=
prepare
(
"UPDATE DISTRICT SET D_NEXT_O_ID=-1 WHERE D_ID=-1"
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateDistrict"
);
for
(
int
d_id
=
1
;
d_id
<=
bench
.
districtsPerWarehouse
;
d_id
++)
{
prep
=
prepare
(
"SELECT MIN(NO_O_ID) FROM NEW_ORDER "
+
"WHERE NO_D_ID=? AND NO_W_ID=?"
);
...
...
@@ -573,7 +573,7 @@ public class BenchCThread {
prep
.
setInt
(
1
,
no_o_id
);
prep
.
setInt
(
2
,
d_id
);
prep
.
setInt
(
3
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"deleteNewOrder"
);
prep
=
prepare
(
"SELECT O_C_ID FROM ORDERS "
+
"WHERE O_ID=? AND O_D_ID=? AND O_W_ID=?"
);
prep
.
setInt
(
1
,
no_o_id
);
...
...
@@ -589,14 +589,14 @@ public class BenchCThread {
prep
.
setInt
(
2
,
no_o_id
);
prep
.
setInt
(
3
,
d_id
);
prep
.
setInt
(
4
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateOrders"
);
prep
=
prepare
(
"UPDATE ORDER_LINE SET OL_DELIVERY_D=? "
+
"WHERE OL_O_ID=? AND OL_D_ID=? AND OL_W_ID=?"
);
prep
.
setTimestamp
(
1
,
datetime
);
prep
.
setInt
(
2
,
no_o_id
);
prep
.
setInt
(
3
,
d_id
);
prep
.
setInt
(
4
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateOrderLine"
);
prep
=
prepare
(
"SELECT SUM(OL_AMOUNT) FROM ORDER_LINE "
+
"WHERE OL_O_ID=? AND OL_D_ID=? AND OL_W_ID=?"
);
prep
.
setInt
(
1
,
no_o_id
);
...
...
@@ -612,7 +612,7 @@ public class BenchCThread {
prep
.
setInt
(
2
,
no_o_id
);
prep
.
setInt
(
3
,
d_id
);
prep
.
setInt
(
4
,
warehouseId
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateCustomer"
);
}
}
db
.
commit
();
...
...
@@ -625,7 +625,7 @@ public class BenchCThread {
ResultSet
rs
;
prep
=
prepare
(
"UPDATE DISTRICT SET D_NEXT_O_ID=-1 WHERE D_ID=-1"
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateDistrict"
);
prep
=
prepare
(
"SELECT D_NEXT_O_ID FROM DISTRICT "
+
"WHERE D_ID=? AND D_W_ID=?"
);
...
...
h2/src/test/org/h2/test/bench/BenchSimple.java
浏览文件 @
35e27cd5
...
...
@@ -27,7 +27,7 @@ public class BenchSimple implements Bench {
for
(
int
i
=
0
;
i
<
records
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setString
(
2
,
"Hello World "
+
i
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"insertTest"
);
if
(
i
%
commitEvery
==
0
)
{
db
.
commit
();
}
...
...
@@ -70,7 +70,7 @@ public class BenchSimple implements Bench {
for
(
int
i
=
0
;
i
<
records
;
i
++)
{
prep
.
setString
(
1
,
"Hallo Welt"
);
prep
.
setInt
(
2
,
i
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"updateTest"
);
}
db
.
end
();
...
...
@@ -79,7 +79,7 @@ public class BenchSimple implements Bench {
// delete only 50%
for
(
int
i
=
0
;
i
<
records
;
i
+=
2
)
{
prep
.
setInt
(
1
,
i
);
db
.
update
(
prep
);
db
.
update
(
prep
,
"deleteTest"
);
}
db
.
end
();
...
...
h2/src/test/org/h2/test/bench/Database.java
浏览文件 @
35e27cd5
...
...
@@ -216,7 +216,8 @@ class Database {
}
}
public
void
update
(
PreparedStatement
prep
)
throws
Exception
{
public
void
update
(
PreparedStatement
prep
,
String
log
)
throws
Exception
{
test
.
log
(
log
);
prep
.
executeUpdate
();
executedStatements
++;
}
...
...
@@ -295,4 +296,8 @@ class Database {
return
id
;
}
public
Connection
getCurrentConnection
()
{
return
conn
;
}
}
h2/src/test/org/h2/test/bench/TestPerformance.java
浏览文件 @
35e27cd5
...
...
@@ -21,6 +21,7 @@ import org.h2.util.JdbcUtils;
public
class
TestPerformance
{
boolean
collect
;
boolean
log
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
TestPerformance
().
test
(
args
);
...
...
@@ -59,6 +60,8 @@ public class TestPerformance {
init
=
true
;
}
else
if
(
args
[
i
].
equals
(
"-out"
))
{
out
=
args
[++
i
];
}
else
if
(
args
[
i
].
equals
(
"-log"
))
{
log
=
Boolean
.
valueOf
(
args
[++
i
]).
booleanValue
();
}
}
openResults
(
init
);
...
...
@@ -215,4 +218,10 @@ public class TestPerformance {
bench
.
runTest
();
}
public
void
log
(
String
s
)
{
if
(
log
)
{
System
.
out
.
println
(
s
);
}
}
}
h2/src/test/org/h2/test/bench/test.properties
浏览文件 @
35e27cd5
db
1
=
H2, org.h2.Driver, jdbc:h2:data/test;LOCK_TIMEOUT=10000;LOCK_MODE=3, sa, sa
db
2
=
H2, org.h2.Driver, jdbc:h2:data/test;LOCK_TIMEOUT=10000;LOCK_MODE=3, sa, sa
xdb2
=
H2 (XTEA), org.h2.Driver, jdbc:h2:data/test_xtea;LOCK_TIMEOUT=10000;LOCK_MODE=3;CIPHER=XTEA, sa, sa 123
xdb3
=
H2 (AES), org.h2.Driver, jdbc:h2:data/test_aes;LOCK_TIMEOUT=10000;LOCK_MODE=3;CIPHER=AES, sa, sa 123
xdb4
=
H2, org.h2.Driver, jdbc:h2:data/test;LOCK_TIMEOUT=10000;LOCK_MODE=3;write_mode_log=rws;write_delay=0, sa, sa
db2
=
HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:data/test;hsqldb.default_table_type=cached;sql.enforce_size=true, sa
db1
=
H2_PG, org.postgresql.Driver, jdbc:postgresql://localhost:5435/h2test, sa, sa
xdb2
=
HSQLDB, org.hsqldb.jdbcDriver, jdbc:hsqldb:data/test;hsqldb.default_table_type=cached;sql.enforce_size=true, sa
db3
=
Derby, org.apache.derby.jdbc.EmbeddedDriver, jdbc:derby:data/test;create=true, sa, sa
db4
=
H2, org.h2.Driver, jdbc:h2:tcp://localhost/data/testServer;LOCK_TIMEOUT=10000;LOCK_MODE=3, sa, sa
...
...
@@ -23,9 +25,10 @@ postgresql.datetime = TIMESTAMP
derby.datetime
=
TIMESTAMP
oracle.datetime
=
TIMESTAMP
test1
=
org.h2.test.bench.BenchSimple
test2
=
org.h2.test.bench.BenchA
test3
=
org.h2.test.bench.BenchB
test
4
=
org.h2.test.bench.BenchC
#
test1 = org.h2.test.bench.BenchSimple
#
test2 = org.h2.test.bench.BenchA
#
test3 = org.h2.test.bench.BenchB
test
1
=
org.h2.test.bench.BenchC
size
=
400
#size = 400
size
=
10
\ No newline at end of file
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
35e27cd5
--- special grammar and test cases ---------------------------------------------------------------------------------------------
CALL REGEXP_REPLACE('Kaboooom', 'o+', 'o');
> 'Kabom'
> -------
> Kabom
> rows: 1
SELECT 'Hello' ~ 'He.*' T1, 'HELLO' ~ 'He.*' F2, CAST('HELLO' AS VARCHAR_IGNORECASE) ~ 'He.*' T3;
> T1 F2 T3
> ---- ----- ----
> TRUE FALSE TRUE
> rows: 1
SELECT 'Hello' ~* 'He.*' T1, 'HELLO' ~* 'He.*' T2, 'hallo' ~* 'He.*' F3;
> T1 T2 F3
> ---- ---- -----
> TRUE TRUE FALSE
> rows: 1
SELECT 'Hello' !~* 'Ho.*' T1, 'HELLO' !~* 'He.*' F2, 'hallo' !~* 'Ha.*' F3;
> T1 F2 F3
> ---- ----- -----
> TRUE FALSE FALSE
> rows: 1
create table test(parent int primary key, child int, foreign key(child) references (parent));
> ok
...
...
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
35e27cd5
call timestamp '2007-07-26 18:44:26.109000 +02:00';
> 1;
create table test(id int primary key);
begin;
insert into test values(1);
rollback;
insert into test values(2);
rollback;
begin;
insert into test values(3);
commit;
insert into test values(4);
rollback;
select group_concat(id order by id) from test;
> 2,3,4;
drop table test;
create table test();
insert into test values();
ALTER TABLE TEST ADD ID INTEGER;
...
...
h2/src/test/org/h2/test/unit/TestPattern.java
浏览文件 @
35e27cd5
...
...
@@ -15,7 +15,7 @@ public class TestPattern extends TestBase {
public
void
test
()
throws
Exception
{
CompareMode
mode
=
new
CompareMode
(
null
,
null
);
CompareLike
comp
=
new
CompareLike
(
mode
,
null
,
null
,
null
);
CompareLike
comp
=
new
CompareLike
(
mode
,
null
,
null
,
null
,
false
);
test
(
comp
,
"B"
,
"%_"
);
test
(
comp
,
"A"
,
"A%"
);
test
(
comp
,
"A"
,
"A%%"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论