Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3d8bb1e5
提交
3d8bb1e5
authored
10月 31, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 407: The TriggerAdapter didn't work with CLOB and BLOB columns.
上级
8ff1491a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
14 行删除
+28
-14
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+24
-12
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+4
-2
没有找到文件。
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
3d8bb1e5
...
@@ -478,21 +478,25 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -478,21 +478,25 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
/**
/**
* Returns the value as a java.io.InputStream.
* Returns the value as a java.io.InputStream.
* This is only supported if the
* result set was created using a Blob object.
*
*
* @param columnIndex (1,2,...)
* @param columnIndex (1,2,...)
* @return the value
* @return the value
*/
*/
public
InputStream
getBinaryStream
(
int
columnIndex
)
throws
SQLException
{
public
InputStream
getBinaryStream
(
int
columnIndex
)
throws
SQLException
{
Blob
b
=
(
Blob
)
get
(
columnIndex
);
return
asInputStream
(
get
(
columnIndex
));
return
b
==
null
?
null
:
b
.
getBinaryStream
();
}
private
static
InputStream
asInputStream
(
Object
o
)
throws
SQLException
{
if
(
o
==
null
)
{
return
null
;
}
else
if
(
o
instanceof
Blob
)
{
return
((
Blob
)
o
).
getBinaryStream
();
}
return
(
InputStream
)
o
;
}
}
/**
/**
* Returns the value as a java.io.InputStream.
* Returns the value as a java.io.InputStream.
* This is only supported if the
* result set was created using a Blob object.
*
*
* @param columnLabel the column label
* @param columnLabel the column label
* @return the value
* @return the value
...
@@ -510,8 +514,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -510,8 +514,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* @return the value
* @return the value
*/
*/
public
Blob
getBlob
(
int
columnIndex
)
throws
SQLException
{
public
Blob
getBlob
(
int
columnIndex
)
throws
SQLException
{
Blob
b
=
(
Blob
)
get
(
columnIndex
);
return
(
Blob
)
get
(
columnIndex
);
return
b
==
null
?
null
:
b
;
}
}
/**
/**
...
@@ -596,20 +599,29 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -596,20 +599,29 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
/**
/**
* Returns the value as a java.io.Reader.
* Returns the value as a java.io.Reader.
* This is only supported for CLOB data.
* This is only supported if the
* result set was created using a Clob or Reader object.
*
*
* @param columnIndex (1,2,...)
* @param columnIndex (1,2,...)
* @return the value
* @return the value
*/
*/
public
Reader
getCharacterStream
(
int
columnIndex
)
throws
SQLException
{
public
Reader
getCharacterStream
(
int
columnIndex
)
throws
SQLException
{
Clob
c
=
(
Clob
)
get
(
columnIndex
);
return
asReader
(
get
(
columnIndex
));
return
c
==
null
?
null
:
c
.
getCharacterStream
();
}
private
static
Reader
asReader
(
Object
o
)
throws
SQLException
{
if
(
o
==
null
)
{
return
null
;
}
else
if
(
o
instanceof
Clob
)
{
return
((
Clob
)
o
).
getCharacterStream
();
}
return
(
Reader
)
o
;
}
}
/**
/**
* Returns the value as a java.io.Reader.
* Returns the value as a java.io.Reader.
* This is only supported if the
* This is only supported if the
* result set was created using a Clob object.
* result set was created using a Clob o
r Reader o
bject.
*
*
* @param columnLabel the column label
* @param columnLabel the column label
* @return the value
* @return the value
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
3d8bb1e5
...
@@ -120,11 +120,11 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
...
@@ -120,11 +120,11 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
conn
=
getConnection
(
"trigger"
);
conn
=
getConnection
(
"trigger"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"drop table if exists test"
);
stat
.
execute
(
"drop table if exists test"
);
stat
.
execute
(
"create table test(id int)"
);
stat
.
execute
(
"create table test(id int
, c clob, b blob
)"
);
stat
.
execute
(
"create table message(name varchar)"
);
stat
.
execute
(
"create table message(name varchar)"
);
stat
.
execute
(
"create trigger test_insert before insert, update, delete on test "
+
stat
.
execute
(
"create trigger test_insert before insert, update, delete on test "
+
"for each row call \""
+
TestTriggerAdapter
.
class
.
getName
()
+
"\""
);
"for each row call \""
+
TestTriggerAdapter
.
class
.
getName
()
+
"\""
);
stat
.
execute
(
"insert into test values(1)"
);
stat
.
execute
(
"insert into test values(1
, 'hello', 'abcd'
)"
);
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
rs
.
next
();
...
@@ -211,6 +211,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
...
@@ -211,6 +211,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
throw
new
RuntimeException
(
"Expected: 2 got: "
+
newRow
.
getString
(
1
));
throw
new
RuntimeException
(
"Expected: 2 got: "
+
newRow
.
getString
(
1
));
}
}
}
}
newRow
.
getCharacterStream
(
2
);
newRow
.
getBinaryStream
(
3
);
newRow
.
updateInt
(
1
,
newRow
.
getInt
(
1
)
*
10
);
newRow
.
updateInt
(
1
,
newRow
.
getInt
(
1
)
*
10
);
}
}
conn
.
createStatement
().
execute
(
"insert into message values('"
+
buff
.
toString
()
+
"')"
);
conn
.
createStatement
().
execute
(
"insert into message values('"
+
buff
.
toString
()
+
"')"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论