Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
373e16a7
提交
373e16a7
authored
13 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SimpleResultSet now how minimal BLOB and CLOB support.
上级
cc66deec
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
279 行增加
和
61 行删除
+279
-61
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+102
-59
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+177
-2
没有找到文件。
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
373e16a7
...
@@ -652,7 +652,59 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -652,7 +652,59 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* @return the value
* @return the value
*/
*/
public
Array
getArray
(
int
columnIndex
)
throws
SQLException
{
public
Array
getArray
(
int
columnIndex
)
throws
SQLException
{
return
new
SimpleArray
((
Object
[])
get
(
columnIndex
));
Object
[]
o
=
(
Object
[])
get
(
columnIndex
);
return
o
==
null
?
null
:
new
SimpleArray
(
o
);
}
/**
* Returns the value as a java.io.Reader.
* This is only supported for CLOB data.
*
* @param columnIndex (1,2,...)
* @return the value
*/
public
Reader
getCharacterStream
(
int
columnIndex
)
throws
SQLException
{
Clob
c
=
(
Clob
)
get
(
columnIndex
);
return
c
==
null
?
null
:
c
.
getCharacterStream
();
}
/**
* Returns the value as a java.sql.Clob.
* This is only supported if the
* result set was created using a Clob object.
*
* @param columnIndex (1,2,...)
* @return the value
*/
public
Clob
getClob
(
int
columnIndex
)
throws
SQLException
{
Clob
c
=
(
Clob
)
get
(
columnIndex
);
return
c
==
null
?
null
:
c
;
}
/**
* Returns the value as a java.sql.Blob.
* This is only supported if the
* result set was created using a Blob object.
*
* @param columnIndex (1,2,...)
* @return the value
*/
public
Blob
getBlob
(
int
columnIndex
)
throws
SQLException
{
Blob
b
=
(
Blob
)
get
(
columnIndex
);
return
b
==
null
?
null
:
b
;
}
/**
* 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,...)
* @return the value
*/
public
InputStream
getBinaryStream
(
int
columnIndex
)
throws
SQLException
{
Blob
b
=
(
Blob
)
get
(
columnIndex
);
return
b
==
null
?
null
:
b
.
getBinaryStream
();
}
}
/**
/**
...
@@ -725,6 +777,53 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -725,6 +777,53 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
return
getArray
(
findColumn
(
columnLabel
));
return
getArray
(
findColumn
(
columnLabel
));
}
}
/**
* Returns the value as a java.io.Reader.
* This is only supported if the
* result set was created using a Clob object.
*
* @param columnLabel the column label
* @return the value
*/
public
Reader
getCharacterStream
(
String
columnLabel
)
throws
SQLException
{
return
getCharacterStream
(
findColumn
(
columnLabel
));
}
/**
* Returns the value as a java.sql.Clob.
* This is only supported if the
* result set was created using a Clob object.
*
* @param columnLabel the column label
* @return the value
*/
public
Clob
getClob
(
String
columnLabel
)
throws
SQLException
{
return
getClob
(
findColumn
(
columnLabel
));
}
/**
* Returns the value as a java.sql.Blob.
* This is only supported if the
* result set was created using a Blob object.
*
* @param columnLabel the column label
* @return the value
*/
public
Blob
getBlob
(
String
columnLabel
)
throws
SQLException
{
return
getBlob
(
findColumn
(
columnLabel
));
}
/**
* 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
* @return the value
*/
public
InputStream
getBinaryStream
(
String
columnLabel
)
throws
SQLException
{
return
getBinaryStream
(
findColumn
(
columnLabel
));
}
// ---- result set meta data ---------------------------------------------
// ---- result set meta data ---------------------------------------------
...
@@ -1177,13 +1276,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1177,13 +1276,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
return
null
;
return
null
;
}
}
/**
* INTERNAL
*/
public
InputStream
getBinaryStream
(
int
columnIndex
)
{
return
null
;
}
/**
/**
* @deprecated INTERNAL
* @deprecated INTERNAL
*/
*/
...
@@ -1205,13 +1297,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1205,13 +1297,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
Reader
getCharacterStream
(
int
columnIndex
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
@@ -1331,13 +1416,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1331,13 +1416,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
Blob
getBlob
(
int
i
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
@@ -1345,13 +1423,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1345,13 +1423,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
Clob
getClob
(
int
i
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
@@ -1369,7 +1440,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1369,7 +1440,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
/**
/**
* INTERNAL
* INTERNAL
*/
*/
public
Ref
getRef
(
int
i
)
throws
SQLException
{
public
Ref
getRef
(
int
columnIndex
)
throws
SQLException
{
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
...
@@ -1401,13 +1472,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1401,13 +1472,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
InputStream
getBinaryStream
(
String
columnLabel
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* @deprecated INTERNAL
* @deprecated INTERNAL
*/
*/
...
@@ -1429,13 +1493,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1429,13 +1493,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
Reader
getCharacterStream
(
String
columnLabel
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
@@ -1460,7 +1517,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1460,7 +1517,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
/**
/**
* INTERNAL
* INTERNAL
*/
*/
public
Object
getObject
(
int
i
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
public
Object
getObject
(
int
columnIndex
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
...
@@ -1499,13 +1556,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1499,13 +1556,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
Blob
getBlob
(
String
colName
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
@@ -1513,13 +1563,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
...
@@ -1513,13 +1563,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw
getUnsupportedException
();
throw
getUnsupportedException
();
}
}
/**
* INTERNAL
*/
public
Clob
getClob
(
String
colName
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
373e16a7
...
@@ -10,12 +10,18 @@ import java.awt.Button;
...
@@ -10,12 +10,18 @@ import java.awt.Button;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseEvent
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.io.Reader
;
import
java.io.Writer
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.net.ServerSocket
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.sql.Blob
;
import
java.sql.Clob
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.Date
;
import
java.sql.Date
;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
...
@@ -220,13 +226,18 @@ public class TestTools extends TestBase {
...
@@ -220,13 +226,18 @@ public class TestTools extends TestBase {
rs
.
addColumn
(
"h"
,
Types
.
ARRAY
,
0
,
0
);
rs
.
addColumn
(
"h"
,
Types
.
ARRAY
,
0
,
0
);
rs
.
addColumn
(
"i"
,
Types
.
TIME
,
0
,
0
);
rs
.
addColumn
(
"i"
,
Types
.
TIME
,
0
,
0
);
rs
.
addColumn
(
"j"
,
Types
.
TIMESTAMP
,
0
,
0
);
rs
.
addColumn
(
"j"
,
Types
.
TIMESTAMP
,
0
,
0
);
rs
.
addColumn
(
"k"
,
Types
.
CLOB
,
0
,
0
);
rs
.
addColumn
(
"l"
,
Types
.
BLOB
,
0
,
0
);
Date
d
=
Date
.
valueOf
(
"2001-02-03"
);
Date
d
=
Date
.
valueOf
(
"2001-02-03"
);
byte
[]
b
=
{(
byte
)
0xab
};
byte
[]
b
=
{(
byte
)
0xab
};
Object
[]
a
=
{
1
,
2
};
Object
[]
a
=
{
1
,
2
};
Time
t
=
Time
.
valueOf
(
"10:20:30"
);
Time
t
=
Time
.
valueOf
(
"10:20:30"
);
Timestamp
ts
=
Timestamp
.
valueOf
(
"2002-03-04 10:20:30"
);
Timestamp
ts
=
Timestamp
.
valueOf
(
"2002-03-04 10:20:30"
);
rs
.
addRow
(
1
,
b
,
true
,
d
,
"10.3"
,
Math
.
PI
,
"-3"
,
a
,
t
,
ts
);
Clob
clob
=
new
SimpleClob
(
"Hello World"
);
Blob
blob
=
new
SimpleBlob
(
new
byte
[]{(
byte
)
1
,
(
byte
)
2
});
rs
.
addRow
(
1
,
b
,
true
,
d
,
"10.3"
,
Math
.
PI
,
"-3"
,
a
,
t
,
ts
,
clob
,
blob
);
rs
.
addRow
(
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
rs
.
next
();
rs
.
next
();
...
@@ -280,11 +291,52 @@ public class TestTools extends TestBase {
...
@@ -280,11 +291,52 @@ public class TestTools extends TestBase {
assertTrue
(
ts
==
rs
.
getTimestamp
(
"j"
));
assertTrue
(
ts
==
rs
.
getTimestamp
(
"j"
));
assertTrue
(
ts
==
rs
.
getTimestamp
(
10
));
assertTrue
(
ts
==
rs
.
getTimestamp
(
10
));
assertTrue
(
clob
==
rs
.
getClob
(
"k"
));
assertTrue
(
clob
==
rs
.
getClob
(
11
));
assertTrue
(
blob
==
rs
.
getBlob
(
"l"
));
assertTrue
(
blob
==
rs
.
getBlob
(
12
));
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
(
ResultSet
)
rs
).
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
(
ResultSet
)
rs
).
getString
(
1
1
);
getString
(
1
3
);
assertThrows
(
ErrorCode
.
COLUMN_NOT_FOUND_1
,
(
ResultSet
)
rs
).
assertThrows
(
ErrorCode
.
COLUMN_NOT_FOUND_1
,
(
ResultSet
)
rs
).
getString
(
"NOT_FOUND"
);
getString
(
"NOT_FOUND"
);
rs
.
next
();
assertEquals
(
0
,
rs
.
getLong
(
1
));
assertTrue
(
rs
.
wasNull
());
assertEquals
(
null
,
rs
.
getBytes
(
2
));
assertTrue
(
rs
.
wasNull
());
assertFalse
(
rs
.
getBoolean
(
3
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getDate
(
4
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getBigDecimal
(
5
));
assertTrue
(
rs
.
wasNull
());
assertEquals
(
0.0
,
rs
.
getDouble
(
5
));
assertTrue
(
rs
.
wasNull
());
assertEquals
(
0.0
,
rs
.
getDouble
(
6
));
assertTrue
(
rs
.
wasNull
());
assertEquals
(
0.0
,
rs
.
getFloat
(
6
));
assertTrue
(
rs
.
wasNull
());
assertEquals
(
0
,
rs
.
getInt
(
7
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getArray
(
8
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getTime
(
9
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getTimestamp
(
10
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getClob
(
11
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getCharacterStream
(
11
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getBlob
(
12
));
assertTrue
(
rs
.
wasNull
());
assertNull
(
rs
.
getBinaryStream
(
12
));
assertTrue
(
rs
.
wasNull
());
// all 'updateX' methods are not supported
// all 'updateX' methods are not supported
for
(
Method
m:
rs
.
getClass
().
getMethods
())
{
for
(
Method
m:
rs
.
getClass
().
getMethods
())
{
if
(
m
.
getName
().
startsWith
(
"update"
))
{
if
(
m
.
getName
().
startsWith
(
"update"
))
{
...
@@ -329,6 +381,7 @@ public class TestTools extends TestBase {
...
@@ -329,6 +381,7 @@ public class TestTools extends TestBase {
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertFalse
(
rs
.
isClosed
());
assertFalse
(
rs
.
isClosed
());
assertEquals
(
1
,
rs
.
getRow
());
assertEquals
(
1
,
rs
.
getRow
());
assertTrue
(
rs
.
next
());
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
assertThrows
(
ErrorCode
.
NO_DATA_AVAILABLE
,
(
ResultSet
)
rs
).
assertThrows
(
ErrorCode
.
NO_DATA_AVAILABLE
,
(
ResultSet
)
rs
).
getInt
(
1
);
getInt
(
1
);
...
@@ -819,4 +872,126 @@ public class TestTools extends TestBase {
...
@@ -819,4 +872,126 @@ public class TestTools extends TestBase {
deleteDb
(
"testSplit"
);
deleteDb
(
"testSplit"
);
}
}
/**
* A simple Clob implementation.
*/
class
SimpleClob
implements
Clob
{
private
final
String
data
;
SimpleClob
(
String
data
)
{
this
.
data
=
data
;
}
public
void
free
()
throws
SQLException
{
// ignore
}
public
InputStream
getAsciiStream
()
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
Reader
getCharacterStream
()
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
Reader
getCharacterStream
(
long
pos
,
long
length
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
String
getSubString
(
long
pos
,
int
length
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
long
length
()
throws
SQLException
{
return
data
.
length
();
}
public
long
position
(
String
searchstr
,
long
start
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
long
position
(
Clob
searchstr
,
long
start
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
OutputStream
setAsciiStream
(
long
pos
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
Writer
setCharacterStream
(
long
pos
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
int
setString
(
long
pos
,
String
str
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
int
setString
(
long
pos
,
String
str
,
int
offset
,
int
len
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
void
truncate
(
long
len
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
}
/**
* A simple Blob implementation.
*/
class
SimpleBlob
implements
Blob
{
private
final
byte
[]
data
;
SimpleBlob
(
byte
[]
data
)
{
this
.
data
=
data
;
}
public
void
free
()
throws
SQLException
{
// ignore
}
public
InputStream
getBinaryStream
()
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
InputStream
getBinaryStream
(
long
pos
,
long
length
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
byte
[]
getBytes
(
long
pos
,
int
length
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
long
length
()
throws
SQLException
{
return
data
.
length
;
}
public
long
position
(
byte
[]
pattern
,
long
start
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
long
position
(
Blob
pattern
,
long
start
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
OutputStream
setBinaryStream
(
long
pos
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
int
setBytes
(
long
pos
,
byte
[]
bytes
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
int
setBytes
(
long
pos
,
byte
[]
bytes
,
int
offset
,
int
len
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
public
void
truncate
(
long
len
)
throws
SQLException
{
throw
new
UnsupportedOperationException
();
}
}
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论