Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
11005db3
提交
11005db3
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More tests
上级
4ca5c7bd
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
3 行删除
+53
-3
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+53
-3
没有找到文件。
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
11005db3
...
...
@@ -6,6 +6,9 @@
*/
package
org
.
h2
.
test
.
jdbc
;
import
java.io.ByteArrayInputStream
;
import
java.io.Reader
;
import
java.io.StringReader
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.sql.CallableStatement
;
...
...
@@ -23,6 +26,7 @@ import java.util.Collections;
import
org.h2.constant.ErrorCode
;
import
org.h2.test.TestBase
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.upgrade.v1_1.util.IOUtils
;
import
org.h2.util.Utils
;
/**
...
...
@@ -40,7 +44,7 @@ public class TestCallableStatement extends TestBase {
}
@Override
public
void
test
()
throws
SQL
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"callableStatement"
);
Connection
conn
=
getConnection
(
"callableStatement"
);
testOutParameter
(
conn
);
...
...
@@ -142,6 +146,7 @@ public class TestCallableStatement extends TestBase {
call
.
registerOutParameter
(
1
,
Types
.
BINARY
);
call
.
execute
();
assertEquals
(
11
,
call
.
getBytes
(
1
).
length
);
assertEquals
(
11
,
call
.
getBlob
(
1
).
length
());
call
.
setDate
(
2
,
java
.
sql
.
Date
.
valueOf
(
"2000-01-01"
));
call
.
registerOutParameter
(
1
,
Types
.
DATE
);
...
...
@@ -187,7 +192,7 @@ public class TestCallableStatement extends TestBase {
}
}
private
void
testPrepare
(
Connection
conn
)
throws
SQL
Exception
{
private
void
testPrepare
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
CallableStatement
call
;
ResultSet
rs
;
...
...
@@ -216,7 +221,7 @@ public class TestCallableStatement extends TestBase {
stat
.
execute
(
"CREATE ALIAS testCall FOR \""
+
getClass
().
getName
()
+
".testCall\""
);
call
=
conn
.
prepareCall
(
"{CALL testCall(?, ?, ?, ?)}"
);
call
.
setInt
(
"A"
,
50
);
call
.
setString
(
2
,
"abc"
);
call
.
setString
(
"B"
,
"abc"
);
long
t
=
System
.
currentTimeMillis
();
call
.
setTimestamp
(
"C"
,
new
Timestamp
(
t
));
call
.
setTimestamp
(
"D"
,
Timestamp
.
valueOf
(
"2001-02-03 10:20:30.0"
));
...
...
@@ -261,6 +266,10 @@ public class TestCallableStatement extends TestBase {
assertTrue
(
call
.
getBoolean
(
"A"
));
assertEquals
(
"ABC"
,
call
.
getString
(
2
));
Reader
r
=
call
.
getCharacterStream
(
2
);
assertEquals
(
"ABC"
,
IOUtils
.
readStringAndClose
(
r
,
-
1
));
r
=
call
.
getNCharacterStream
(
2
);
assertEquals
(
"ABC"
,
IOUtils
.
readStringAndClose
(
r
,
-
1
));
assertEquals
(
"ABC"
,
call
.
getString
(
"B"
));
assertEquals
(
"ABC"
,
call
.
getNString
(
2
));
assertEquals
(
"ABC"
,
call
.
getNString
(
"B"
));
...
...
@@ -287,6 +296,47 @@ public class TestCallableStatement extends TestBase {
}
catch
(
SQLException
e
)
{
// expected exception
}
call
.
setCharacterStream
(
"B"
,
new
StringReader
(
"xyz"
));
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setCharacterStream
(
"B"
,
new
StringReader
(
"xyz-"
),
3
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setCharacterStream
(
"B"
,
new
StringReader
(
"xyz-"
),
3L
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setAsciiStream
(
"B"
,
new
ByteArrayInputStream
(
"xyz"
.
getBytes
(
"UTF-8"
)));
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setAsciiStream
(
"B"
,
new
ByteArrayInputStream
(
"xyz-"
.
getBytes
(
"UTF-8"
)),
3
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setAsciiStream
(
"B"
,
new
ByteArrayInputStream
(
"xyz-"
.
getBytes
(
"UTF-8"
)),
3L
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setClob
(
"B"
,
new
StringReader
(
"xyz"
));
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setClob
(
"B"
,
new
StringReader
(
"xyz-"
),
3
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setNClob
(
"B"
,
new
StringReader
(
"xyz"
));
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setNClob
(
"B"
,
new
StringReader
(
"xyz-"
),
3
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setString
(
"B"
,
"xyz"
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
call
.
setNString
(
"B"
,
"xyz"
);
call
.
executeUpdate
();
assertEquals
(
"XYZ"
,
call
.
getString
(
"B"
));
// test for exceptions after closing
call
.
close
();
assertThrows
(
ErrorCode
.
OBJECT_CLOSED
,
call
).
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论