Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c5b9bf04
提交
c5b9bf04
authored
7月 29, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
496327b2
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
99 行增加
和
56 行删除
+99
-56
ant-build.properties
h2/ant-build.properties
+1
-1
build.xml
h2/build.xml
+7
-7
build.html
h2/src/docsrc/html/build.html
+1
-1
history.html
h2/src/docsrc/html/history.html
+5
-1
tutorial.html
h2/src/docsrc/html/tutorial.html
+18
-5
CommandRemote.java
h2/src/main/org/h2/command/CommandRemote.java
+0
-4
Constants.java
h2/src/main/org/h2/engine/Constants.java
+1
-5
DatabaseCloser.java
h2/src/main/org/h2/engine/DatabaseCloser.java
+1
-1
Engine.java
h2/src/main/org/h2/engine/Engine.java
+1
-1
ConditionNot.java
h2/src/main/org/h2/expression/ConditionNot.java
+1
-3
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+37
-25
CacheLRU.java
h2/src/main/org/h2/util/CacheLRU.java
+1
-1
DataType.java
h2/src/main/org/h2/value/DataType.java
+1
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+24
-0
没有找到文件。
h2/ant-build.properties
浏览文件 @
c5b9bf04
#
Tue Jul 24 08:17:27
CEST 2007
#
Sun Jul 29 20:39:45
CEST 2007
javac
=
javac
benchmark.drivers.dir
=
C
\:
/data/java
path.servlet.jar
=
C
\:
/data/classpath/servlet-api.jar
...
...
h2/build.xml
浏览文件 @
c5b9bf04
...
...
@@ -47,15 +47,15 @@
</target>
<target
name=
"codeswitchPrepare"
>
<javac
executable=
"${javac}"
srcdir=
"src/tools"
debug=
"true"
includes=
"org/h2/tools/code/CodeSwitch.java"
/>
<javac
executable=
"${javac}"
srcdir=
"src/tools"
de
stdir=
"bin"
de
bug=
"true"
includes=
"org/h2/tools/code/CodeSwitch.java"
/>
</target>
<target
name=
"codeswitchJdk13"
depends=
"codeswitchPrepare"
>
<propertyfile
file=
"ant-build.properties"
>
<entry
key=
"jdk"
value=
"1.3"
/>
</propertyfile>
<java
classname=
"org.h2.tools.code.CodeSwitch"
fork=
"true"
dir=
"
src/tools
"
>
<arg
line=
"+JDK13 -JDK14 -JDK16 ../main/org/h2"
/>
<java
classname=
"org.h2.tools.code.CodeSwitch"
fork=
"true"
dir=
"
bin
"
>
<arg
line=
"+JDK13 -JDK14 -JDK16 ../
src/
main/org/h2"
/>
</java>
</target>
...
...
@@ -63,8 +63,8 @@
<propertyfile
file=
"ant-build.properties"
>
<entry
key=
"jdk"
value=
"1.4"
/>
</propertyfile>
<java
classname=
"org.h2.tools.code.CodeSwitch"
fork=
"true"
dir=
"
src/tools
"
>
<arg
line=
"-JDK13 +JDK14 -JDK16 ../main/org/h2"
/>
<java
classname=
"org.h2.tools.code.CodeSwitch"
fork=
"true"
dir=
"
bin
"
>
<arg
line=
"-JDK13 +JDK14 -JDK16 ../
src/
main/org/h2"
/>
</java>
</target>
...
...
@@ -72,8 +72,8 @@
<propertyfile
file=
"ant-build.properties"
>
<entry
key=
"jdk"
value=
"1.6"
/>
</propertyfile>
<java
classname=
"org.h2.tools.code.CodeSwitch"
fork=
"true"
dir=
"
src/tools
"
>
<arg
line=
"-JDK13 +JDK16 +JDK14 ../main/org/h2"
/>
<java
classname=
"org.h2.tools.code.CodeSwitch"
fork=
"true"
dir=
"
bin
"
>
<arg
line=
"-JDK13 +JDK16 +JDK14 ../
src/
main/org/h2"
/>
</java>
</target>
...
...
h2/src/docsrc/html/build.html
浏览文件 @
c5b9bf04
...
...
@@ -67,7 +67,7 @@ The version is currently 1.0.<year><month><day>. Example:
<
dependency
>
<
groupId
>
com.h2database
<
/groupId
>
<
artifactId
>
h2
<
/artifactId
>
<
version
>
1.0.20070
429
<
/version
>
<
version
>
1.0.20070
617
<
/version
>
<
/dependency
>
</pre>
...
...
h2/src/docsrc/html/history.html
浏览文件 @
c5b9bf04
...
...
@@ -826,8 +826,9 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>
Better support large transactions, large updates / deletes: allow tables without primary key
</li><li>
Support Oracle RPAD and LPAD(string, n[, pad]) (truncate the end if longer)
</li><li>
Allow editing NULL values in the Console
</li><li>
Updatable result sets: DatabaseMetaData.ownUpdatesAreVisible = true
.
</li><li>
Updatable result sets: DatabaseMetaData.ownUpdatesAreVisible = true
(for insert, delete, update)
Simple solution: automatically calls 'refresh' when the result was changed.
Compare with other databases.
</li></ul>
<h3>
Priority 2
</h3>
...
...
@@ -1083,6 +1084,9 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</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><li>
Add a role DBA (like ADMIN).
</li><li>
Automatic mode: jdbc:h2:auto: (embedded mode if possible, if not use server mode).
Problem: what to do when server stops while others are connected to it.
</li></ul>
<h3>
Not Planned
</h3>
...
...
h2/src/docsrc/html/tutorial.html
浏览文件 @
c5b9bf04
...
...
@@ -383,20 +383,20 @@ The recommended way to upgrade from one version of the database engine to the ne
version is to create a backup of the database (in the form of a SQL script) using the old engine,
and then execute the SQL script using the new engine.
<h3>
Backup
</h3>
<h3>
Backup
using the Script Tool
</h3>
There are different ways to backup a database. For example, it is possible to copy the database files.
However, this is not recommended while the database is in use. Also, the database files are not human readable
and quite large. The recommended way to backup a database is to create a compressed SQL script file.
This can be done using the
backup
tool:
This can be done using the
Script
tool:
<pre>
java org.h2.tools.
Backup
-url jdbc:h2:~/test -user sa -script test.zip -options compression zip
java org.h2.tools.
Script
-url jdbc:h2:~/test -user sa -script test.zip -options compression zip
</pre>
It is also possible to use the SQL command SCRIPT to create the backup of the database.
For more information about the options, see the SQL command SCRIPT.
The backup can be done remotely, however the file will be created on the server side.
The built in FTP server could be used to retrieve the file from the server.
It is also possible to use the SQL command SCRIPT to create the backup of the database.
<h3>
Restore
</h3>
<h3>
Restore
from a Script
</h3>
To restore a database from a SQL script file, you can use the RunScript tool:
<pre>
java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
...
...
@@ -409,6 +409,19 @@ SQL script files may contain references to other script files, in the form of
RUNSCRIPT commands. However, when using the server mode, the references script files
need to be available on the server side.
<h3>
Online Backup
</h3>
The BACKUP SQL statement and the Backup tool both create a zip file
with all database files. However, the contents of this file are not human readable.
Other than the SCRIPT statement, the BACKUP statement does not lock the
database objects, and therefore does not block other users. The resulting
backup is transactionally consistent:
<pre>
BACKUP TO 'backup.zip'
</pre>
The Backup tool (org.h2.tools.Backup) can not be used to create a online backup;
the database must not be in use while running this program.
<br
/><a
name=
"open_office"
></a>
<h2>
Using OpenOffice Base
</h2>
OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database
...
...
h2/src/main/org/h2/command/CommandRemote.java
浏览文件 @
c5b9bf04
...
...
@@ -89,10 +89,6 @@ public class CommandRemote implements CommandInterface {
transfer
.
writeInt
(
SessionRemote
.
COMMAND_GET_META_DATA
).
writeInt
(
id
).
writeInt
(
objectId
);
session
.
done
(
transfer
);
int
columnCount
=
transfer
.
readInt
();
if
(
result
!=
null
)
{
result
.
close
();
result
=
null
;
}
result
=
new
ResultRemote
(
session
,
transfer
,
objectId
,
columnCount
,
-
1
);
break
;
}
catch
(
IOException
e
)
{
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
c5b9bf04
...
...
@@ -17,11 +17,7 @@ import org.h2.message.TraceSystem;
* - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - ant jarClient, check jar file size
*
* - Compile with JDK 1.3, 1.4, 1.5 and 1.6:
* set path=C:\jdk1.3.1_19\bin;%PATH%
* set JAVA_HOME=C:\jdk1.3.1_19
* ant codeswitchJdk13
* ant compile
* - Compile with JDK 1.4, 1.5 and 1.6:
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0
* ant codeswitchJdk16
...
...
h2/src/main/org/h2/engine/DatabaseCloser.java
浏览文件 @
c5b9bf04
...
...
@@ -9,7 +9,7 @@ import java.lang.ref.WeakReference;
public
class
DatabaseCloser
extends
Thread
{
private
final
boolean
shutdownHook
;
private
WeakReference
databaseRef
;
private
volatile
WeakReference
databaseRef
;
private
int
delayInMillis
;
DatabaseCloser
(
Database
db
,
int
delayInMillis
,
boolean
shutdownHook
)
{
...
...
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
c5b9bf04
...
...
@@ -94,7 +94,7 @@ public class Engine {
break
;
}
// we found a database that is currently closing
// wait a bit to avoid a busy loop
// wait a bit to avoid a busy loop
(the method is synchronized)
try
{
Thread
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
...
...
h2/src/main/org/h2/expression/ConditionNot.java
浏览文件 @
c5b9bf04
...
...
@@ -45,9 +45,7 @@ public class ConditionNot extends Condition {
Expression
expr
=
condition
.
optimize
(
session
);
Expression
e2
=
expr
.
getNotIfPossible
(
session
);
if
(
e2
!=
null
)
{
e2
=
e2
.
optimize
(
session
);
expr
=
e2
;
return
e2
;
return
e2
.
optimize
(
session
);
}
if
(
expr
.
isConstant
())
{
Value
v
=
expr
.
getValue
(
session
);
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
c5b9bf04
...
...
@@ -29,6 +29,7 @@ import java.util.HashSet;
import
java.util.Properties
;
import
org.h2.Driver
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.ObjectUtils
;
import
org.h2.util.ScriptReader
;
...
...
@@ -325,13 +326,14 @@ public class PgServerThread implements Runnable {
String
query
=
readString
();
ScriptReader
reader
=
new
ScriptReader
(
new
StringReader
(
query
));
while
(
true
)
{
Statement
stat
=
null
;
try
{
String
s
=
reader
.
readStatement
();
if
(
s
==
null
)
{
break
;
}
s
=
getSQL
(
s
);
Statement
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
boolean
result
=
stat
.
execute
(
s
);
if
(
result
)
{
ResultSet
rs
=
stat
.
getResultSet
();
...
...
@@ -346,6 +348,8 @@ public class PgServerThread implements Runnable {
}
}
catch
(
SQLException
e
)
{
sendErrorResponse
(
e
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
sendReadyForQuery
();
...
...
@@ -568,33 +572,41 @@ public class PgServerThread implements Runnable {
}
private
void
initDb
()
throws
SQLException
{
ResultSet
rs
=
conn
.
getMetaData
().
getTables
(
null
,
"PG_CATALOG"
,
"PG_VERSION"
,
null
);
boolean
tableFound
=
rs
.
next
();
Statement
stat
=
conn
.
createStatement
();
if
(
tableFound
)
{
rs
=
stat
.
executeQuery
(
"SELECT VERION FROM PG_CATALOG.PG_VERSION"
);
if
(
rs
.
next
())
{
if
(
rs
.
getInt
(
1
)
==
1
)
{
// already installed
return
;
Statement
stat
=
null
;
ResultSet
rs
=
null
;
Reader
r
=
null
;
try
{
rs
=
conn
.
getMetaData
().
getTables
(
null
,
"PG_CATALOG"
,
"PG_VERSION"
,
null
);
boolean
tableFound
=
rs
.
next
();
stat
=
conn
.
createStatement
();
if
(
tableFound
)
{
rs
=
stat
.
executeQuery
(
"SELECT VERION FROM PG_CATALOG.PG_VERSION"
);
if
(
rs
.
next
())
{
if
(
rs
.
getInt
(
1
)
==
1
)
{
// already installed
return
;
}
}
}
}
Reader
r
=
new
InputStreamReader
(
getClass
().
getResourceAsStream
(
"pg_catalog.sql"
));
r
=
new
BufferedReader
(
r
);
ScriptReader
reader
=
new
ScriptReader
(
r
);
while
(
true
)
{
String
sql
=
reader
.
readStatement
()
;
if
(
sql
==
null
)
{
break
;
r
=
new
InputStreamReader
(
getClass
().
getResourceAsStream
(
"pg_catalog.sql"
));
ScriptReader
reader
=
new
ScriptReader
(
new
BufferedReader
(
r
));
while
(
true
)
{
String
sql
=
reader
.
readStatement
(
);
if
(
sql
==
null
)
{
break
;
}
stat
.
execute
(
sql
)
;
}
stat
.
execute
(
sql
);
}
reader
.
close
();
rs
=
stat
.
executeQuery
(
"SELECT OID FROM PG_CATALOG.PG_TYPE"
);
while
(
rs
.
next
())
{
types
.
add
(
ObjectUtils
.
getInteger
(
rs
.
getInt
(
1
)));
reader
.
close
();
rs
=
stat
.
executeQuery
(
"SELECT OID FROM PG_CATALOG.PG_TYPE"
);
while
(
rs
.
next
())
{
types
.
add
(
ObjectUtils
.
getInteger
(
rs
.
getInt
(
1
)));
}
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
rs
);
IOUtils
.
closeSilently
(
r
);
}
}
...
...
h2/src/main/org/h2/util/CacheLRU.java
浏览文件 @
c5b9bf04
...
...
@@ -252,7 +252,7 @@ public class CacheLRU implements Cache {
public
void
setMaxSize
(
int
maxKb
)
throws
SQLException
{
int
newSize
=
maxKb
*
1024
/
4
;
new
Size
=
newSize
<
0
?
0
:
newSize
;
max
Size
=
newSize
<
0
?
0
:
newSize
;
// can not resize, otherwise existing records are lost
// resize(maxSize);
removeOldIfRequired
();
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
c5b9bf04
...
...
@@ -437,7 +437,7 @@ public class DataType {
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
values
[
i
]
=
DataType
.
convertToValue
(
session
,
list
[
i
],
Value
.
NULL
);
}
v
=
array
==
null
?
(
Value
)
ValueNull
.
INSTANCE
:
ValueArray
.
get
(
values
);
v
=
ValueArray
.
get
(
values
);
break
;
}
default
:
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
c5b9bf04
...
...
@@ -94,6 +94,30 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
/*
Hi!
Openfire server uses this script to setup a user permissions
on the fresh-installed server. The database is [current] HSQLDB :
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET SCHEMA PUBLIC
Unfortunately, this does not work (first string has a different semantic)
on the H2...
Wrong user name or password [08004-55]
Could you please correct documentation ?
Tutorial --> Upgrade, Backup, and Restore --> Backup
The documentation states :
java org.h2.tools.Backup -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
The "tools.Backup" has no such options ! Seems you meant "tools.Script"
[root@ftp bin]# java -cp "h2.jar" org.h2.tools.Backup -help
java org.h2.tools.Backup [-file <filename>] [-dir <dir>] [-db <database>] [-quiet]
=
Could you please cross-link this topic with
Features --> Database File Layout --> Backup
=
What is the difference between "SCRIPT" and "BACKUP" statements ?
merge html-ja
rename Performance > Comparison [/Compatibility]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论