Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
875a893f
提交
875a893f
authored
11月 13, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ResultSet.getObject for CLOB or BLOB will return a java.sql.Clob / java.sql.Blob object.
上级
2479e6a1
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
90 行增加
和
18 行删除
+90
-18
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+21
-1
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+42
-0
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+2
-13
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+10
-2
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+8
-2
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+7
-0
没有找到文件。
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
875a893f
...
...
@@ -456,6 +456,20 @@ public class SysProperties {
* transaction is easier.
*/
public
static
final
int
RESERVE_MEMORY
=
getIntSetting
(
"h2.reserveMemory"
,
512
*
1024
);
/**
* System property <code>h2.returnLobObjects</code>.<br />
* When true, ResultSet.getObject for CLOB or BLOB will return a
* java.sql.Clob / java.sql.Blob object. When set to false, it will return a
* java.io.Reader / java.io.InputStream.
* <p>
* In version 1.0, it is disabled by default.
* </p>
* <p>
* In version 1.1, it is enabled by default.
* </p>
*/
public
static
final
boolean
RETURN_LOB_OBJECTS
=
getBooleanSetting
(
"h2.returnLobObjects"
,
Constants
.
VERSION
>
1.0
);
/**
* System property <code>h2.reuseSpaceAfter</code> (default: 16).<br />
...
...
@@ -524,6 +538,12 @@ public class SysProperties {
*/
public
static
final
boolean
SORT_NULLS_HIGH
=
getBooleanSetting
(
"h2.sortNullsHigh"
,
false
);
/**
* System property <code>h2.splitFileSizeShift</code> (default: 30).<br />
* The maximum file size of a split file is 1L << x.
*/
public
static
final
long
SPLIT_FILE_SIZE_SHIFT
=
getIntSetting
(
"h2.splitFileSizeShift"
,
20
);
/**
* System property <code>h2.traceIO</code> (default: false).<br />
* Trace all I/O operations.
...
...
@@ -592,7 +612,7 @@ public class SysProperties {
}
return
defaultValue
;
}
/**
* INTERNAL
*/
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
875a893f
...
...
@@ -36,6 +36,7 @@ import org.h2.message.Trace;
import
org.h2.message.TraceObject
;
import
org.h2.result.ResultInterface
;
import
org.h2.util.JdbcConnectionListener
;
import
org.h2.util.ObjectUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLob
;
...
...
@@ -1532,5 +1533,46 @@ public class JdbcConnection extends TraceObject implements Connection {
public
String
toString
()
{
return
getTraceObjectName
()
+
": url="
+
url
+
" user="
+
user
;
}
/**
* Convert an object to the default Java object for the given SQL type. For
* example, LOB objects are converted to java.sql.Clob / java.sql.Blob.
*
* @param v the value
* @return the object
*/
Object
convertToDefaultObject
(
Value
v
)
throws
SQLException
{
Object
o
;
switch
(
v
.
getType
())
{
case
Value
.
CLOB
:
{
if
(
SysProperties
.
RETURN_LOB_OBJECTS
)
{
int
id
=
getNextId
(
TraceObject
.
CLOB
);
o
=
new
JdbcClob
(
session
,
this
,
v
,
id
);
}
else
{
o
=
v
.
getObject
();
}
break
;
}
case
Value
.
BLOB
:
{
if
(
SysProperties
.
RETURN_LOB_OBJECTS
)
{
int
id
=
getNextId
(
TraceObject
.
BLOB
);
o
=
new
JdbcBlob
(
session
,
this
,
v
,
id
);
}
else
{
o
=
v
.
getObject
();
}
break
;
}
case
Value
.
JAVA_OBJECT
:
if
(
Constants
.
SERIALIZE_JAVA_OBJECTS
)
{
o
=
ObjectUtils
.
deserialize
(
v
.
getBytesNoCopy
());
}
else
{
o
=
v
.
getObject
();
}
break
;
default
:
o
=
v
.
getObject
();
}
return
o
;
}
}
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
875a893f
...
...
@@ -34,7 +34,6 @@ import java.sql.SQLXML;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SessionInterface
;
import
org.h2.message.Message
;
import
org.h2.message.TraceObject
;
...
...
@@ -460,12 +459,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
try
{
debugCodeCall
(
"getObject"
,
columnIndex
);
Value
v
=
get
(
columnIndex
);
if
(
Constants
.
SERIALIZE_JAVA_OBJECTS
)
{
if
(
v
.
getType
()
==
Value
.
JAVA_OBJECT
)
{
return
ObjectUtils
.
deserialize
(
v
.
getBytesNoCopy
());
}
}
return
v
.
getObject
();
return
conn
.
convertToDefaultObject
(
v
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -484,12 +478,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
try
{
debugCodeCall
(
"getObject"
,
columnName
);
Value
v
=
get
(
columnName
);
if
(
Constants
.
SERIALIZE_JAVA_OBJECTS
)
{
if
(
v
.
getType
()
==
Value
.
JAVA_OBJECT
)
{
return
ObjectUtils
.
deserialize
(
v
.
getBytesNoCopy
());
}
}
return
v
.
getObject
();
return
conn
.
convertToDefaultObject
(
v
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
875a893f
...
...
@@ -743,11 +743,19 @@ public class TestLob extends TestBase {
if
(
clob
)
{
Reader
rt
=
rs
.
getCharacterStream
(
2
);
checkReader
(
rt
,
getRandomReader
(
size
,
id
),
-
1
);
checkReader
((
Reader
)
rs
.
getObject
(
2
),
getRandomReader
(
size
,
id
),
-
1
);
Object
obj
=
rs
.
getObject
(
2
);
if
(
obj
instanceof
Clob
)
{
obj
=
((
Clob
)
obj
).
getCharacterStream
();
}
checkReader
((
Reader
)
obj
,
getRandomReader
(
size
,
id
),
-
1
);
}
else
{
InputStream
in
=
rs
.
getBinaryStream
(
2
);
checkStream
(
in
,
getRandomStream
(
size
,
id
),
-
1
);
checkStream
((
InputStream
)
rs
.
getObject
(
2
),
getRandomStream
(
size
,
id
),
-
1
);
Object
obj
=
rs
.
getObject
(
2
);
if
(
obj
instanceof
Blob
)
{
obj
=
((
Blob
)
obj
).
getBinaryStream
();
}
checkStream
((
InputStream
)
obj
,
getRandomStream
(
size
,
id
),
-
1
);
}
}
trace
(
"select="
+
(
System
.
currentTimeMillis
()
-
time
));
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
875a893f
...
...
@@ -15,6 +15,7 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Types
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.test.TestBase
;
import
org.h2.value.DataType
;
...
...
@@ -218,8 +219,13 @@ public class TestMetaData extends TestBase {
assertEquals
(
"java.io.InputStream"
,
meta
.
getColumnClassName
(
1
));
assertEquals
(
"java.io.Reader"
,
meta
.
getColumnClassName
(
2
));
rs
.
next
();
assertEquals
(
"java.io.ByteArrayInputStream"
,
rs
.
getObject
(
1
).
getClass
().
getName
());
assertEquals
(
"java.io.BufferedReader"
,
rs
.
getObject
(
2
).
getClass
().
getName
());
if
(
SysProperties
.
RETURN_LOB_OBJECTS
)
{
assertTrue
(
rs
.
getObject
(
1
)
instanceof
java
.
sql
.
Blob
);
assertTrue
(
rs
.
getObject
(
2
)
instanceof
java
.
sql
.
Clob
);
}
else
{
assertEquals
(
"java.io.ByteArrayInputStream"
,
rs
.
getObject
(
1
).
getClass
().
getName
());
assertEquals
(
"java.io.BufferedReader"
,
rs
.
getObject
(
2
).
getClass
().
getName
());
}
stat
.
executeUpdate
(
"DROP TABLE t"
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
875a893f
...
...
@@ -26,6 +26,7 @@ import java.sql.Types;
import
java.util.Calendar
;
import
java.util.TimeZone
;
import
org.h2.constant.SysProperties
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -858,6 +859,12 @@ public class TestResultSet extends TestBase {
assertResultSetMeta
(
rs
,
2
,
new
String
[]
{
"ID"
,
"VALUE"
},
new
int
[]
{
Types
.
INTEGER
,
Types
.
CLOB
},
new
int
[]
{
10
,
Integer
.
MAX_VALUE
},
new
int
[]
{
0
,
0
});
rs
.
next
();
Object
obj
=
rs
.
getObject
(
2
);
if
(
SysProperties
.
RETURN_LOB_OBJECTS
)
{
assertTrue
(
obj
instanceof
java
.
sql
.
Clob
);
}
else
{
assertTrue
(
obj
instanceof
java
.
io
.
Reader
);
}
string
=
rs
.
getString
(
2
);
assertTrue
(
string
!=
null
&&
string
.
equals
(
"Test"
));
assertTrue
(!
rs
.
wasNull
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论