Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
19f5f2de
Unverified
提交
19f5f2de
authored
7月 09, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
7月 09, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1276 from katzyn/misc
Improve support of ARRAY and SQLXML in JDBC layer
上级
cc9c9bb1
fb37cc7c
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
102 行增加
和
25 行删除
+102
-25
JdbcCallableStatement.java
h2/src/main/org/h2/jdbc/JdbcCallableStatement.java
+21
-8
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+42
-4
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+3
-2
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+7
-7
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+29
-4
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcCallableStatement.java
浏览文件 @
19f5f2de
...
...
@@ -872,21 +872,30 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements
}
/**
* [Not supported] Returns the value of the specified column as a SQLXML
* object.
* Returns the value of the specified column as a SQLXML object.
*
* @param parameterIndex the parameter index (1, 2, ...)
* @return the value
* @throws SQLException if the column is not found or if this object is
* closed
*/
@Override
public
SQLXML
getSQLXML
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupported
(
"SQLXML"
);
checkRegistered
(
parameterIndex
);
return
getOpenResultSet
().
getSQLXML
(
parameterIndex
);
}
/**
* [Not supported] Returns the value of the specified column as a SQLXML
* object.
* Returns the value of the specified column as a SQLXML object.
*
* @param parameterName the parameter name
* @return the value
* @throws SQLException if the column is not found or if this object is
* closed
*/
@Override
public
SQLXML
getSQLXML
(
String
parameterName
)
throws
SQLException
{
throw
unsupported
(
"SQLXML"
);
return
getSQLXML
(
getIndexForName
(
parameterName
)
);
}
/**
...
...
@@ -1584,12 +1593,16 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements
}
/**
* [Not supported] Sets the value of a parameter as a SQLXML object.
* Sets the value of a parameter as a SQLXML object.
*
* @param parameterName the parameter name
* @param x the value
* @throws SQLException if this object is closed
*/
@Override
public
void
setSQLXML
(
String
parameterName
,
SQLXML
x
)
throws
SQLException
{
throw
unsupported
(
"SQLXML"
);
setSQLXML
(
getIndexForName
(
parameterName
),
x
);
}
/**
...
...
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
19f5f2de
...
...
@@ -2489,19 +2489,57 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
}
/**
* [Not supported]
* Updates a column in the current or insert row.
*
* @param columnIndex (1,2,...)
* @param x the value
* @param length the length
* @throws SQLException if the result set is closed or not updatable
*/
@Override
public
void
updateArray
(
int
columnIndex
,
Array
x
)
throws
SQLException
{
throw
unsupported
(
"setArray"
);
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"updateArray("
+
columnIndex
+
", x);"
);
}
checkClosed
();
Value
v
;
if
(
x
==
null
)
{
v
=
ValueNull
.
INSTANCE
;
}
else
{
v
=
DataType
.
convertToValue
(
stat
.
session
,
x
.
getArray
(),
Value
.
ARRAY
);
}
update
(
columnIndex
,
v
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
/**
* [Not supported]
* Updates a column in the current or insert row.
*
* @param columnLabel the column label
* @param x the value
* @param length the length
* @throws SQLException if the result set is closed or not updatable
*/
@Override
public
void
updateArray
(
String
columnLabel
,
Array
x
)
throws
SQLException
{
throw
unsupported
(
"setArray"
);
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"updateArray("
+
quote
(
columnLabel
)
+
", x);"
);
}
checkClosed
();
Value
v
;
if
(
x
==
null
)
{
v
=
ValueNull
.
INSTANCE
;
}
else
{
v
=
DataType
.
convertToValue
(
stat
.
session
,
x
.
getArray
(),
Value
.
ARRAY
);
}
update
(
columnLabel
,
v
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
/**
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
19f5f2de
...
...
@@ -7,6 +7,7 @@ package org.h2.value;
import
java.lang.reflect.Array
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.util.Arrays
;
import
org.h2.engine.Constants
;
...
...
@@ -135,8 +136,8 @@ public class ValueArray extends Value {
}
@Override
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
{
throw
throwUnsupportedExceptionForType
(
"PreparedStatement.set"
);
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
{
prep
.
setArray
(
parameterIndex
,
prep
.
getConnection
().
createArrayOf
(
"NULL"
,
(
Object
[])
getObject
())
);
}
@Override
...
...
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
19f5f2de
...
...
@@ -91,8 +91,6 @@ public class TestCallableStatement extends TestDb {
getRef
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getRowId
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getSQLXML
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getURL
(
"a"
);
...
...
@@ -102,8 +100,6 @@ public class TestCallableStatement extends TestDb {
getRef
(
"a"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getRowId
(
"a"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getSQLXML
(
"a"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
setURL
(
1
,
(
URL
)
null
);
...
...
@@ -116,9 +112,6 @@ public class TestCallableStatement extends TestDb {
setURL
(
"a"
,
(
URL
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
setRowId
(
"a"
,
(
RowId
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
setSQLXML
(
"a"
,
(
SQLXML
)
null
);
}
private
void
testCallWithResultSet
(
Connection
conn
)
throws
SQLException
{
...
...
@@ -332,6 +325,8 @@ public class TestCallableStatement extends TestDb {
assertEquals
(
"ABC"
,
call
.
getClob
(
"B"
).
getSubString
(
1
,
3
));
assertEquals
(
"ABC"
,
call
.
getNClob
(
2
).
getSubString
(
1
,
3
));
assertEquals
(
"ABC"
,
call
.
getNClob
(
"B"
).
getSubString
(
1
,
3
));
assertEquals
(
"ABC"
,
call
.
getSQLXML
(
2
).
getString
());
assertEquals
(
"ABC"
,
call
.
getSQLXML
(
"B"
).
getString
());
try
{
call
.
getString
(
100
);
...
...
@@ -397,6 +392,11 @@ public class TestCallableStatement extends TestDb {
call
.
setNString
(
"B"
,
"xyz"
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
SQLXML
xml
=
conn
.
createSQLXML
();
xml
.
setString
(
"<x>xyz</x>"
);
call
.
setSQLXML
(
"B"
,
xml
);
call
.
executeUpdate
();
assertEquals
(
"<X>XYZ</X>"
,
call
.
getString
(
"B"
));
// test for exceptions after closing
call
.
close
();
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
19f5f2de
...
...
@@ -165,10 +165,6 @@ public class TestResultSet extends TestDb {
updateRef
(
1
,
(
Ref
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateRef
(
"x"
,
(
Ref
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateArray
(
1
,
(
Array
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateArray
(
"x"
,
(
Array
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateRowId
(
1
,
(
RowId
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
...
...
@@ -1807,6 +1803,35 @@ public class TestResultSet extends TestDb {
assertThrows
(
ErrorCode
.
OBJECT_CLOSED
,
array
).
getResultSet
();
assertFalse
(
rs
.
next
());
try
(
Statement
s
=
conn
.
createStatement
(
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_UPDATABLE
))
{
rs
=
s
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
rs
.
updateArray
(
2
,
conn
.
createArrayOf
(
"INT"
,
new
Object
[]
{
10
,
20
}));
rs
.
updateRow
();
assertTrue
(
rs
.
next
());
rs
.
updateArray
(
"VALUE"
,
conn
.
createArrayOf
(
"INT"
,
new
Object
[]
{
11
,
22
}));
rs
.
updateRow
();
assertFalse
(
rs
.
next
());
rs
.
moveToInsertRow
();
rs
.
updateInt
(
1
,
3
);
rs
.
updateArray
(
2
,
null
);
rs
.
insertRow
();
}
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
new
Object
[]
{
10
,
20
},
(
Object
[])
rs
.
getObject
(
2
));
assertTrue
(
rs
.
next
());
assertEquals
(
2
,
rs
.
getInt
(
1
));
assertEquals
(
new
Object
[]
{
11
,
22
},
(
Object
[])
rs
.
getObject
(
2
));
assertTrue
(
rs
.
next
());
assertEquals
(
3
,
rs
.
getInt
(
1
));
assertNull
(
rs
.
getObject
(
2
));
assertFalse
(
rs
.
next
());
stat
.
execute
(
"DROP TABLE TEST"
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论