Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d3337916
提交
d3337916
authored
1月 25, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reading input streams from the classpath is now supported.
上级
b9e57e4d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
40 行增加
和
3 行删除
+40
-3
help.csv
h2/src/docsrc/help/help.csv
+13
-3
advanced.html
h2/src/docsrc/html/advanced.html
+6
-0
FileSystemDisk.java
h2/src/main/org/h2/store/fs/FileSystemDisk.java
+10
-0
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+11
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
d3337916
...
...
@@ -124,13 +124,16 @@ statements; each statement must end with ';'. This command can be used to
restore a database from a backup. The password must be in single quotes; it is
case sensitive and can contain spaces.
Instead of a file name, an URL may be used.
To read a stream from the classpath, use the prefix 'classpath:'.
The compression algorithm must match the one used when creating the script. When
using encryption, only DEFLATE and LZF are supported (LZF is faster but uses more space).
Instead of a file, an URL may be used.
Admin rights are required to execute this command.
","
RUNSCRIPT FROM 'backup'
RUNSCRIPT FROM 'backup
.sql
'
"
"Commands (DML)","SCRIPT","
...
...
@@ -3310,8 +3313,10 @@ parsed as NULL. All columns of type VARCHAR.
The BOM (the byte-order-mark) character 0xfeff at the beginning of the file is ignored.
This function can be used like a table: ""SELECT * FROM CSVREAD(...)"".
Instead of a file, an URL may be used, for example
""jar:file:///c:/temp/example.zip!/org/example/nested.zip"".
""jar:file:///c:/temp/example.zip!/org/example/nested.csv"".
To read a stream from the classpath, use the prefix ""classpath:"".
Admin rights are required to execute this command.
","
...
...
@@ -3322,6 +3327,7 @@ CALL CSVREAD('test2.csv', 'ID|NAME', 'UTF-8', '|');
-- Read a semicolon-separated file
SELECT * FROM CSVREAD('data/test.csv', NULL, NULL, ';');
SELECT ""Last Name"" FROM CSVREAD('address.csv');
SELECT ""Last Name"" FROM CSVREAD('classpath:/org/acme/data/address.csv');
"
"Functions (System)","CSVWRITE","
...
...
@@ -3369,7 +3375,11 @@ FILE_READ(fileNameString [,encodingString])
Returns the contents of a file. If only one parameter is supplied, the data are
returned as a BLOB. If two parameters are used, the data is returned as a CLOB
(text). The second parameter is the character set to use, NULL meaning the
default character set for this system. File names and URLs are supported.
default character set for this system.
File names and URLs are supported.
To read a stream from the classpath, use the prefix ""classpath:"".
Admin rights are required to execute this command.
","
SELECT LENGTH(FILE_READ('~/.h2.server.properties')) LEN;
...
...
h2/src/docsrc/html/advanced.html
浏览文件 @
d3337916
...
...
@@ -1428,6 +1428,12 @@ As an example, to use the the <code>nio</code> file system, use the following da
To register a new file system, extend the classes
<code>
org.h2.store.fs.FileSystem, FileObject
</code>
,
and call the method
<code>
FileSystem.register
</code>
before using it.
</p>
<p>
For input streams (but not for random access files), URLs may be used in addition to the registered file systems.
Example:
<code>
jar:file:///c:/temp/example.zip!/org/example/nested.csv
</code>
.
To read a stream from the classpath, use the prefix
<code>
classpath:
</code>
, as in
<code>
classpath:org/h2/samples/newsfeed.sql
</code>
.
</p>
<h2
id=
"database_upgrade"
>
Database Upgrade
</h2>
<p>
...
...
h2/src/main/org/h2/store/fs/FileSystemDisk.java
浏览文件 @
d3337916
...
...
@@ -34,6 +34,8 @@ public class FileSystemDisk extends FileSystem {
// could maybe implemented using some other means
private
static
final
boolean
IS_FILE_SYSTEM_CASE_INSENSITIVE
=
File
.
separatorChar
==
'\\'
;
private
static
final
String
CLASSPATH_PREFIX
=
"classpath:"
;
protected
FileSystemDisk
()
{
// nothing to do
}
...
...
@@ -394,6 +396,14 @@ public class FileSystemDisk extends FileSystem {
public
InputStream
openFileInputStream
(
String
fileName
)
throws
IOException
{
if
(
fileName
.
indexOf
(
':'
)
>
1
)
{
// if the : is in position 1, a windows file access is assumed: C:.. or D:
if
(
fileName
.
startsWith
(
CLASSPATH_PREFIX
))
{
fileName
=
fileName
.
substring
(
CLASSPATH_PREFIX
.
length
());
InputStream
in
=
getClass
().
getClassLoader
().
getResourceAsStream
(
fileName
);
if
(
in
==
null
)
{
throw
new
FileNotFoundException
(
"resource "
+
fileName
);
}
return
in
;
}
// otherwise an URL is assumed
URL
url
=
new
URL
(
fileName
);
InputStream
in
=
url
.
openStream
();
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
d3337916
...
...
@@ -34,6 +34,7 @@ public class TestRunscript extends TestBase implements Trigger {
}
public
void
test
()
throws
Exception
{
testRunscriptFromClasspath
();
testCancelScript
();
testEncoding
();
testClobPrimaryKey
();
...
...
@@ -42,6 +43,16 @@ public class TestRunscript extends TestBase implements Trigger {
deleteDb
(
"runscript"
);
}
private
void
testRunscriptFromClasspath
()
throws
Exception
{
deleteDb
(
"runscript"
);
Connection
conn
;
conn
=
getConnection
(
"runscript"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"runscript from 'classpath:org/h2/samples/newsfeed.sql'"
);
stat
.
execute
(
"select * from version"
);
conn
.
close
();
}
private
void
testCancelScript
()
throws
Exception
{
deleteDb
(
"runscript"
);
Connection
conn
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论