Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5bdfd153
提交
5bdfd153
authored
4月 10, 2016
作者:
Niklas Mehner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prevent internal properties (numServer, server*) from being set.
上级
372346d9
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
5 行删除
+25
-5
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+17
-5
TestConnection.java
h2/src/test/org/h2/test/jdbc/TestConnection.java
+8
-0
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
5bdfd153
...
@@ -70,6 +70,9 @@ import java.util.regex.Pattern;
...
@@ -70,6 +70,9 @@ import java.util.regex.Pattern;
*/
*/
public
class
JdbcConnection
extends
TraceObject
implements
Connection
{
public
class
JdbcConnection
extends
TraceObject
implements
Connection
{
private
static
final
String
NUM_SERVERS
=
"numServers"
;
private
static
final
String
PREFIX_SERVER
=
"server"
;
private
static
boolean
keepOpenStackTrace
;
private
static
boolean
keepOpenStackTrace
;
private
final
String
url
;
private
final
String
url
;
...
@@ -1698,6 +1701,10 @@ public class JdbcConnection extends TraceObject implements Connection {
...
@@ -1698,6 +1701,10 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
checkClosed
();
checkClosed
();
if
(
isInternalProperty
(
name
))
{
throw
new
SQLClientInfoException
(
"Property name '"
+
name
+
" is used internally by H2."
,
Collections
.<
String
,
ClientInfoStatus
>
emptyMap
());
}
Pattern
clientInfoNameRegEx
=
getMode
().
supportedClientInfoPropertiesRegEx
;
Pattern
clientInfoNameRegEx
=
getMode
().
supportedClientInfoPropertiesRegEx
;
if
(
clientInfoNameRegEx
!=
null
&&
clientInfoNameRegEx
.
matcher
(
name
).
matches
())
{
if
(
clientInfoNameRegEx
!=
null
&&
clientInfoNameRegEx
.
matcher
(
name
).
matches
())
{
...
@@ -1711,6 +1718,10 @@ public class JdbcConnection extends TraceObject implements Connection {
...
@@ -1711,6 +1718,10 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
}
}
private
boolean
isInternalProperty
(
String
name
)
{
return
NUM_SERVERS
.
equals
(
name
)
||
name
.
startsWith
(
PREFIX_SERVER
);
}
private
Mode
getMode
()
throws
SQLException
{
private
Mode
getMode
()
throws
SQLException
{
return
Mode
.
getInstance
(((
JdbcDatabaseMetaData
)
getMetaData
()).
getMode
());
return
Mode
.
getInstance
(((
JdbcDatabaseMetaData
)
getMetaData
()).
getMode
());
}
}
...
@@ -1763,15 +1774,16 @@ public class JdbcConnection extends TraceObject implements Connection {
...
@@ -1763,15 +1774,16 @@ public class JdbcConnection extends TraceObject implements Connection {
ArrayList
<
String
>
serverList
=
session
.
getClusterServers
();
ArrayList
<
String
>
serverList
=
session
.
getClusterServers
();
Properties
p
=
new
Properties
();
Properties
p
=
new
Properties
();
p
.
setProperty
(
"numServers"
,
String
.
valueOf
(
serverList
.
size
()));
for
(
int
i
=
0
;
i
<
serverList
.
size
();
i
++)
{
p
.
setProperty
(
"server"
+
String
.
valueOf
(
i
),
serverList
.
get
(
i
));
}
for
(
Map
.
Entry
<
String
,
String
>
entry
:
clientInfo
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
clientInfo
.
entrySet
())
{
p
.
setProperty
(
entry
.
getKey
(),
entry
.
getValue
());
p
.
setProperty
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
p
.
setProperty
(
NUM_SERVERS
,
String
.
valueOf
(
serverList
.
size
()));
for
(
int
i
=
0
;
i
<
serverList
.
size
();
i
++)
{
p
.
setProperty
(
PREFIX_SERVER
+
String
.
valueOf
(
i
),
serverList
.
get
(
i
));
}
return
p
;
return
p
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
...
h2/src/test/org/h2/test/jdbc/TestConnection.java
浏览文件 @
5bdfd153
...
@@ -28,6 +28,14 @@ public class TestConnection extends TestBase {
...
@@ -28,6 +28,14 @@ public class TestConnection extends TestBase {
testGetUnsupportedClientInfo
();
testGetUnsupportedClientInfo
();
testSetSupportedClientInfoProperties
();
testSetSupportedClientInfoProperties
();
testSetUnsupportedClientInfoProperties
();
testSetUnsupportedClientInfoProperties
();
testSetInternalProperty
();
}
private
void
testSetInternalProperty
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"clientInfoMySQL"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"numServers"
,
"SomeValue"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"server23"
,
"SomeValue"
);
}
}
private
void
testSetUnsupportedClientInfoProperties
()
throws
SQLException
{
private
void
testSetUnsupportedClientInfoProperties
()
throws
SQLException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论