Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
da02ea7d
提交
da02ea7d
authored
6月 26, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add null checks to JdbcResultSet.updateSQLXML()
上级
84069e20
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
14 行删除
+34
-14
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+12
-2
TestSQLXML.java
h2/src/test/org/h2/test/jdbc/TestSQLXML.java
+22
-12
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
da02ea7d
...
...
@@ -3577,7 +3577,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
debugCode
(
"updateSQLXML("
+
columnIndex
+
", x);"
);
}
checkClosed
();
Value
v
=
conn
.
createClob
(
xmlObject
.
getCharacterStream
(),
-
1
);
Value
v
;
if
(
xmlObject
==
null
)
{
v
=
ValueNull
.
INSTANCE
;
}
else
{
v
=
conn
.
createClob
(
xmlObject
.
getCharacterStream
(),
-
1
);
}
update
(
columnIndex
,
v
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -3599,7 +3604,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
debugCode
(
"updateSQLXML("
+
quote
(
columnLabel
)+
", x);"
);
}
checkClosed
();
Value
v
=
conn
.
createClob
(
xmlObject
.
getCharacterStream
(),
-
1
);
Value
v
;
if
(
xmlObject
==
null
)
{
v
=
ValueNull
.
INSTANCE
;
}
else
{
v
=
conn
.
createClob
(
xmlObject
.
getCharacterStream
(),
-
1
);
}
update
(
columnLabel
,
v
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
h2/src/test/org/h2/test/jdbc/TestSQLXML.java
浏览文件 @
da02ea7d
...
...
@@ -163,6 +163,8 @@ public class TestSQLXML extends TestDb {
testSettersImpl
(
sqlxml
);
// something illegal
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
sqlxml
).
setResult
(
Result
.
class
);
// null
testSettersImpl
(
null
);
}
private
void
assertXML
(
String
actual
)
{
...
...
@@ -172,36 +174,44 @@ public class TestSQLXML extends TestDb {
assertEquals
(
XML
,
actual
);
}
private
void
testSettersImplAssert
(
SQLXML
sqlxml
)
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT X FROM TEST"
);
assertTrue
(
rs
.
next
());
SQLXML
v
=
rs
.
getSQLXML
(
1
);
if
(
sqlxml
!=
null
)
{
assertXML
(
v
.
getString
());
}
else
{
assertNull
(
v
);
}
}
void
testSettersImpl
(
SQLXML
sqlxml
)
throws
SQLException
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET X = ?"
);
prep
.
setSQLXML
(
1
,
sqlxml
);
assertEquals
(
1
,
prep
.
executeUpdate
());
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT X FROM TEST"
);
assertTrue
(
rs
.
next
());
assertXML
(
rs
.
getSQLXML
(
1
).
getString
());
testSettersImplAssert
(
sqlxml
);
prep
.
setObject
(
1
,
sqlxml
);
assertEquals
(
1
,
prep
.
executeUpdate
());
rs
=
stat
.
executeQuery
(
"SELECT X FROM TEST"
);
assertTrue
(
rs
.
next
());
assertXML
(
rs
.
getSQLXML
(
1
).
getString
());
testSettersImplAssert
(
sqlxml
);
Statement
st
=
conn
.
createStatement
(
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_UPDATABLE
);
rs
=
st
.
executeQuery
(
"SELECT * FROM TEST FOR UPDATE"
);
ResultSet
rs
=
st
.
executeQuery
(
"SELECT * FROM TEST FOR UPDATE"
);
assertTrue
(
rs
.
next
());
rs
.
updateSQLXML
(
2
,
sqlxml
);
rs
.
updateRow
();
rs
=
stat
.
executeQuery
(
"SELECT X FROM TEST"
);
testSettersImplAssert
(
sqlxml
);
rs
=
st
.
executeQuery
(
"SELECT * FROM TEST FOR UPDATE"
);
assertTrue
(
rs
.
next
());
assertXML
(
rs
.
getSQLXML
(
1
).
getString
());
rs
.
updateSQLXML
(
"X"
,
sqlxml
);
rs
.
updateRow
();
testSettersImplAssert
(
sqlxml
);
rs
=
st
.
executeQuery
(
"SELECT * FROM TEST FOR UPDATE"
);
assertTrue
(
rs
.
next
());
rs
.
updateObject
(
2
,
sqlxml
);
rs
.
updateRow
();
rs
=
stat
.
executeQuery
(
"SELECT X FROM TEST"
);
assertTrue
(
rs
.
next
());
assertXML
(
rs
.
getSQLXML
(
1
).
getString
());
testSettersImplAssert
(
sqlxml
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论