Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
723696ee
提交
723696ee
authored
3月 16, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved tests
上级
7740acbb
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
35 行增加
和
13 行删除
+35
-13
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+9
-0
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+7
-6
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+1
-1
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+18
-6
没有找到文件。
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
723696ee
...
...
@@ -175,6 +175,15 @@ public class ConnectionInfo implements Cloneable {
}
String
normalizedName
=
FileUtils
.
unwrap
(
FileUtils
.
toRealPath
(
n
));
if
(
normalizedName
.
equals
(
absDir
)
||
!
normalizedName
.
startsWith
(
absDir
))
{
// database name matches the baseDir or
// database name is clearly outside of the baseDir
throw
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
normalizedName
+
" outside "
+
absDir
);
}
if
(
normalizedName
.
charAt
(
absDir
.
length
())
!=
'/'
)
{
// database must be within the directory
// (with baseDir=/test, the database name must not be
// /test2/x and not /test2)
throw
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
normalizedName
+
" outside "
+
absDir
);
}
...
...
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
723696ee
...
...
@@ -119,12 +119,6 @@ public class TcpServerThread implements Runnable {
}
db
=
server
.
checkKeyAndGetDatabaseName
(
db
);
ConnectionInfo
ci
=
new
ConnectionInfo
(
db
);
if
(
baseDir
!=
null
)
{
ci
.
setBaseDir
(
baseDir
);
}
if
(
server
.
getIfExists
())
{
ci
.
setProperty
(
"IFEXISTS"
,
"TRUE"
);
}
ci
.
setOriginalURL
(
originalURL
);
ci
.
setUserName
(
transfer
.
readString
());
ci
.
setUserPasswordHash
(
transfer
.
readBytes
());
...
...
@@ -133,6 +127,13 @@ public class TcpServerThread implements Runnable {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ci
.
setProperty
(
transfer
.
readString
(),
transfer
.
readString
());
}
// override client's requested properties with server settings
if
(
baseDir
!=
null
)
{
ci
.
setBaseDir
(
baseDir
);
}
if
(
server
.
getIfExists
())
{
ci
.
setProperty
(
"IFEXISTS"
,
"TRUE"
);
}
session
=
Engine
.
getInstance
().
createSession
(
ci
);
transfer
.
setSession
(
session
);
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
723696ee
...
...
@@ -180,7 +180,7 @@ public abstract class TestBase {
* @param password the password to use
* @return the connection
*/
p
rotected
Connection
getConnection
(
String
name
,
String
user
,
String
password
)
throws
SQLException
{
p
ublic
Connection
getConnection
(
String
name
,
String
user
,
String
password
)
throws
SQLException
{
return
getConnectionInternal
(
getURL
(
name
,
false
),
user
,
password
);
}
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
723696ee
...
...
@@ -872,18 +872,30 @@ public class TestTools extends TestBase {
"-tcpAllowOthers"
).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test"
,
"sa"
,
""
);
conn
.
close
();
// must not be able to use a different base dir
new
AssertThrows
(
ErrorCode
.
IO_EXCEPTION_1
)
{
public
void
test
()
throws
SQLException
{
getConnection
(
"jdbc:h2:tcp://localhost:9192/../test"
,
"sa"
,
""
);
}};
new
AssertThrows
(
ErrorCode
.
IO_EXCEPTION_1
)
{
public
void
test
()
throws
SQLException
{
getConnection
(
"jdbc:h2:tcp://localhost:9192/../test2/test"
,
"sa"
,
""
);
}};
tcpServer
.
stop
();
Server
.
createTcpServer
(
"-ifExists"
,
"-tcpPassword"
,
"abc"
,
"-baseDir"
,
getBaseDir
(),
"-tcpPort"
,
"9192"
).
start
();
// should not be able to create new db
try
{
// must not be able to create new db
new
AssertThrows
(
ErrorCode
.
DATABASE_NOT_FOUND_1
)
{
public
void
test
()
throws
SQLException
{
getConnection
(
"jdbc:h2:tcp://localhost:9192/test2"
,
"sa"
,
""
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
}};
new
AssertThrows
(
ErrorCode
.
DATABASE_NOT_FOUND_1
)
{
public
void
test
()
throws
SQLException
{
getConnection
(
"jdbc:h2:tcp://localhost:9192/test2;ifexists=false"
,
"sa"
,
""
);
}};
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test"
,
"sa"
,
""
);
conn
.
close
();
new
AssertThrows
(
ErrorCode
.
WRONG_USER_OR_PASSWORD
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论