Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
27026f99
提交
27026f99
authored
10月 06, 2010
作者:
Sergi Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support of stored procedures with OUT parameters in CallableStatement is implemented
上级
f97ba1cb
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
426 行增加
和
276 行删除
+426
-276
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
JdbcCallableStatement.java
h2/src/main/org/h2/jdbc/JdbcCallableStatement.java
+370
-274
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+1
-1
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+53
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
27026f99
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
PreparedStatement.getMetaData() was not always consistent with resulting ResultSet.getMetaData().
<ul><li>
Support of stored procedures with OUT parameters in CallableStatement is implemented.
</li><li>
PreparedStatement.getMetaData() was not always consistent with resulting ResultSet.getMetaData().
</li><li>
The build tool now uses JAVA_HOME for javac as well. Issue 233.
</li><li>
Opening and closing encrypted databases is now much faster.
</li><li>
H2 Console: new experimental feature to support file download and upload,
...
...
h2/src/main/org/h2/jdbc/JdbcCallableStatement.java
浏览文件 @
27026f99
...
...
@@ -16,6 +16,7 @@ import java.sql.CallableStatement;
import
java.sql.Clob
;
import
java.sql.Date
;
import
java.sql.Ref
;
import
java.sql.ResultSetMetaData
;
//## Java 1.6 begin ##
import
java.sql.NClob
;
import
java.sql.SQLXML
;
...
...
@@ -25,890 +26,985 @@ import java.sql.SQLException;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceObject
;
import
org.h2.util.BitField
;
import
org.h2.value.ValueNull
;
/**
* Represents a callable statement.
*
* @author Sergi Vladykin
*/
public
class
JdbcCallableStatement
extends
JdbcPreparedStatement
implements
CallableStatement
{
private
BitField
outParameters
;
private
int
maxOutParameters
;
private
Map
<
String
,
Integer
>
namedParameters
;
JdbcCallableStatement
(
JdbcConnection
conn
,
String
sql
,
int
id
,
int
resultSetType
,
int
resultSetConcurrency
)
{
super
(
conn
,
sql
,
id
,
resultSetType
,
resultSetConcurrency
,
false
);
setTrace
(
session
.
getTrace
(),
TraceObject
.
CALLABLE_STATEMENT
,
id
);
}
/**
* [Not supported]
* @see java.sql.PreparedStatement#executeUpdate()
*/
public
int
executeUpdate
()
throws
SQLException
{
if
(
command
.
isQuery
())
{
super
.
executeQuery
().
next
();
return
0
;
}
return
super
.
executeUpdate
();
}
/**
* @see java.sql.CallableStatement#registerOutParameter(int, int)
*/
public
void
registerOutParameter
(
int
parameterIndex
,
int
sqlType
)
throws
SQLException
{
throw
unsupported
(
"registerOutParameter"
);
registerOutParameter
(
parameterIndex
,
sqlType
,
0
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#registerOutParameter(int, int, int)
*/
public
void
registerOutParameter
(
int
parameterIndex
,
int
sqlType
,
int
scale
)
throws
SQLException
{
throw
unsupported
(
"registerOutParameter"
);
registerOutParameter
(
parameterIndex
,
sqlType
,
scale
,
null
);
}
private
ResultSetMetaData
getCheckedMetaData
()
throws
SQLException
{
ResultSetMetaData
meta
=
getMetaData
();
if
(
meta
==
null
)
{
throw
DbException
.
getUnsupportedException
(
"Supported only for stored procedures calling."
);
}
return
meta
;
}
private
void
checkIndexBounds
(
int
parameterIndex
)
throws
SQLException
{
if
(
parameterIndex
<
1
||
parameterIndex
>
maxOutParameters
)
{
throw
DbException
.
getInvalidValueException
(
Integer
.
toString
(
parameterIndex
),
"parameterIndex"
);
}
}
private
void
registerOutParameter
(
int
parameterIndex
,
int
sqlType
,
int
scale
,
String
typeName
)
throws
SQLException
{
try
{
if
(
outParameters
==
null
)
{
maxOutParameters
=
Math
.
min
(
getParameterMetaData
().
getParameterCount
(),
getCheckedMetaData
()
.
getColumnCount
());
outParameters
=
new
BitField
();
}
checkIndexBounds
(
parameterIndex
);
ParameterInterface
param
=
command
.
getParameters
().
get
(--
parameterIndex
);
if
(
param
.
getParamValue
()
==
null
)
{
param
.
setValue
(
ValueNull
.
INSTANCE
,
false
);
}
outParameters
.
set
(
parameterIndex
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
private
void
checkRegistered
(
int
parameterIndex
)
throws
SQLException
{
try
{
checkIndexBounds
(
parameterIndex
);
if
(!
outParameters
.
get
(
parameterIndex
-
1
))
{
throw
DbException
.
getInvalidValueException
(
Integer
.
toString
(
parameterIndex
),
"parameterIndex"
);
}
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
private
int
getIndexForName
(
String
parameterName
)
throws
SQLException
{
try
{
if
(
namedParameters
==
null
)
{
ResultSetMetaData
meta
=
getCheckedMetaData
();
int
columnCount
=
meta
.
getColumnCount
();
Map
<
String
,
Integer
>
map
=
new
HashMap
<
String
,
Integer
>(
columnCount
);
for
(
int
i
=
1
;
i
<=
columnCount
;
i
++)
{
map
.
put
(
meta
.
getColumnLabel
(
i
),
i
);
}
namedParameters
=
map
;
}
Integer
index
=
namedParameters
.
get
(
parameterName
);
if
(
index
==
null
)
{
throw
DbException
.
getInvalidValueException
(
parameterName
,
"parameterName"
);
}
return
index
;
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
/**
* @see java.sql.CallableStatement#wasNull()
*/
public
boolean
wasNull
()
throws
SQLException
{
if
(
resultSet
==
null
)
{
throw
logAndConvert
(
DbException
.
getUnsupportedException
(
"Method wasNull() should be called only after statement execution and calling a getter method."
));
}
return
resultSet
.
wasNull
();
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getURL(int)
*/
public
boolean
wasNull
()
throws
SQLException
{
throw
unsupported
(
"wasNull"
);
public
URL
getURL
(
int
parameterIndex
)
throws
SQLException
{
checkRegistered
(
parameterIndex
);
return
resultSet
.
getURL
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getString(int)
*/
public
String
getString
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getString
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBoolean(int)
*/
public
boolean
getBoolean
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getBoolean
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getByte(int)
*/
public
byte
getByte
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getByte
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getShort(int)
*/
public
short
getShort
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getShort
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getInt(int)
*/
public
int
getInt
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getInt
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getLong(int)
*/
public
long
getLong
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getLong
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getFloat(int)
*/
public
float
getFloat
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getFloat
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getDouble(int)
*/
public
double
getDouble
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getDouble
(
parameterIndex
);
}
/**
* [Not supported]
* @deprecated
* @see java.sql.CallableStatement#getBigDecimal(int, int)
* @deprecated use <code>getBigDecimal(int parameterIndex)</code>
* or <code>getBigDecimal(String parameterName)</code>
*/
public
BigDecimal
getBigDecimal
(
int
parameterIndex
,
int
scale
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getBigDecimal
(
parameterIndex
,
scale
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBytes(int)
*/
public
byte
[]
getBytes
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getBytes
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getDate(int)
*/
public
Date
getDate
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getDate
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTime(int)
*/
public
Time
getTime
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getTime
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTimestamp(int)
*/
public
Timestamp
getTimestamp
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getTimestamp
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getObject(int)
*/
public
Object
getObject
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getObject
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBigDecimal(int)
*/
public
BigDecimal
getBigDecimal
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getBigDecimal
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getObject(int, java.util.Map)
*/
public
Object
getObject
(
int
parameterIndex
,
Map
<
String
,
Class
<
?
>>
map
)
throws
SQLException
{
throw
unsupportedGet
();
public
Object
getObject
(
int
parameterIndex
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
checkRegistered
(
parameterIndex
);
return
resultSet
.
getObject
(
parameterIndex
,
map
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getRef(int)
*/
public
Ref
getRef
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getRef
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBlob(int)
*/
public
Blob
getBlob
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getBlob
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getClob(int)
*/
public
Clob
getClob
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getClob
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getArray(int)
*/
public
Array
getArray
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getArray
(
parameterIndex
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getDate(int, java.util.Calendar)
*/
public
Date
getDate
(
int
parameterIndex
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getDate
(
parameterIndex
,
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTime(int, java.util.Calendar)
*/
public
Time
getTime
(
int
parameterIndex
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getTime
(
parameterIndex
,
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)
*/
public
Timestamp
getTimestamp
(
int
parameterIndex
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getTimestamp
(
parameterIndex
,
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#registerOutParameter(int, int, java.lang.String)
*/
public
void
registerOutParameter
(
int
paramIndex
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
throw
unsupported
(
"register"
);
public
void
registerOutParameter
(
int
param
eter
Index
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
registerOutParameter
(
parameterIndex
,
sqlType
,
0
,
typeName
);
}
/**
* [Not supported]
*
* @see java.sql.CallableStatement#getURL(java.lang.String)
*/
public
URL
getURL
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getURL
(
getIndexForName
(
parameterName
)
);
}
/**
* [Not supported]
*
* @see java.sql.CallableStatement#getTimestamp(java.lang.String, java.util.Calendar)
*/
public
Timestamp
getTimestamp
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getTimestamp
(
getIndexForName
(
parameterName
),
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTime(java.lang.String, java.util.Calendar)
*/
public
Time
getTime
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getTime
(
getIndexForName
(
parameterName
),
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getDate(java.lang.String, java.util.Calendar)
*/
public
Date
getDate
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getDate
(
getIndexForName
(
parameterName
),
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getArray(java.lang.String)
*/
public
Array
getArray
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getArray
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getClob(java.lang.String)
*/
public
Clob
getClob
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getClob
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBlob(java.lang.String)
*/
public
Blob
getBlob
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getBlob
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getRef(java.lang.String)
*/
public
Ref
getRef
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getRef
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getObject(java.lang.String, java.util.Map)
*/
public
Object
getObject
(
String
parameterName
,
Map
<
String
,
Class
<
?
>>
map
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
public
Object
getObject
(
String
parameterName
,
Map
<
String
,
Class
<
?
>>
map
)
throws
SQLException
{
return
getObject
(
getIndexForName
(
parameterName
),
map
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBigDecimal(java.lang.String)
*/
public
BigDecimal
getBigDecimal
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getBigDecimal
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getObject(java.lang.String)
*/
public
Object
getObject
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getObject
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTimestamp(java.lang.String)
*/
public
Timestamp
getTimestamp
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getTimestamp
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getTime(java.lang.String)
*/
public
Time
getTime
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getTime
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getDate(java.lang.String)
*/
public
Date
getDate
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getDate
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBytes(java.lang.String)
*/
public
byte
[]
getBytes
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getBytes
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getDouble(java.lang.String)
*/
public
double
getDouble
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getDouble
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getFloat(java.lang.String)
*/
public
float
getFloat
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getFloat
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getLong(java.lang.String)
*/
public
long
getLong
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getLong
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getInt(java.lang.String)
*/
public
int
getInt
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getInt
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getShort(java.lang.String)
*/
public
short
getShort
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getShort
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getByte(java.lang.String)
*/
public
byte
getByte
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getByte
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getBoolean(java.lang.String)
*/
public
boolean
getBoolean
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getBoolean
(
getIndexForName
(
parameterName
)
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getString(java.lang.String)
*/
public
String
getString
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getString
(
getIndexForName
(
parameterName
)
);
}
// --- setters --------------------------------------------------
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNull(java.lang.String, int, java.lang.String)
*/
public
void
setNull
(
String
parameterName
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setNull
(
getIndexForName
(
parameterName
),
sqlType
,
typeName
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp, java.util.Calendar)
*/
public
void
setTimestamp
(
String
parameterName
,
Timestamp
x
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setTimestamp
(
getIndexForName
(
parameterName
),
x
,
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time, java.util.Calendar)
*/
public
void
setTime
(
String
parameterName
,
Time
x
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setTime
(
getIndexForName
(
parameterName
),
x
,
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date, java.util.Calendar)
*/
public
void
setDate
(
String
parameterName
,
Date
x
,
Calendar
cal
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setDate
(
getIndexForName
(
parameterName
),
x
,
cal
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, int)
*/
public
void
setCharacterStream
(
String
parameterName
,
Reader
reader
,
int
length
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setCharacterStream
(
getIndexForName
(
parameterName
),
reader
,
length
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object)
*/
public
void
setObject
(
String
parameterName
,
Object
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setObject
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int)
*/
public
void
setObject
(
String
parameterName
,
Object
x
,
int
targetSqlType
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setObject
(
getIndexForName
(
parameterName
),
x
,
targetSqlType
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int, int)
*/
public
void
setObject
(
String
parameterName
,
Object
x
,
int
targetSqlType
,
int
scale
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setObject
(
getIndexForName
(
parameterName
),
x
,
targetSqlType
,
scale
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, int)
*/
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setBinaryStream
(
getIndexForName
(
parameterName
),
x
,
length
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, long)
*/
//## Java 1.6 begin ##
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
,
long
length
)
throws
SQLException
{
setAsciiStream
(
getIndexForName
(
parameterName
),
x
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp)
*/
public
void
setTimestamp
(
String
parameterName
,
Timestamp
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setTimestamp
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time)
*/
public
void
setTime
(
String
parameterName
,
Time
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setTime
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date)
*/
public
void
setDate
(
String
parameterName
,
Date
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setDate
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBytes(java.lang.String, byte[])
*/
public
void
setBytes
(
String
parameterName
,
byte
[]
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setBytes
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setString(java.lang.String, java.lang.String)
*/
public
void
setString
(
String
parameterName
,
String
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setString
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBigDecimal(java.lang.String, java.math.BigDecimal)
*/
public
void
setBigDecimal
(
String
parameterName
,
BigDecimal
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setBigDecimal
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setDouble(java.lang.String, double)
*/
public
void
setDouble
(
String
parameterName
,
double
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setDouble
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setFloat(java.lang.String, float)
*/
public
void
setFloat
(
String
parameterName
,
float
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setFloat
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setLong(java.lang.String, long)
*/
public
void
setLong
(
String
parameterName
,
long
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setLong
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setInt(java.lang.String, int)
*/
public
void
setInt
(
String
parameterName
,
int
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setInt
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setShort(java.lang.String, short)
*/
public
void
setShort
(
String
parameterName
,
short
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setShort
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setByte(java.lang.String, byte)
*/
public
void
setByte
(
String
parameterName
,
byte
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setByte
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBoolean(java.lang.String, boolean)
*/
public
void
setBoolean
(
String
parameterName
,
boolean
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setBoolean
(
getIndexForName
(
parameterName
),
x
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNull(java.lang.String, int)
*/
public
void
setNull
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setNull
(
getIndexForName
(
parameterName
),
sqlType
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setURL(java.lang.String, java.net.URL)
*/
public
void
setURL
(
String
parameterName
,
URL
val
)
throws
SQLException
{
throw
unsupportedParameterName
();
}
/**
* [Not supported]
*/
public
URL
getURL
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupported
(
"url"
);
setURL
(
getIndexForName
(
parameterName
),
val
);
}
// --- other methods --------------------------------------------
/**
*
[Not supported]
*
@see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, java.lang.String)
*/
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
registerOutParameter
(
getIndexForName
(
parameterName
),
sqlType
,
typeName
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, int)
*/
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
,
int
scale
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
registerOutParameter
(
getIndexForName
(
parameterName
),
sqlType
,
scale
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#registerOutParameter(java.lang.String, int)
*/
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
registerOutParameter
(
getIndexForName
(
parameterName
),
sqlType
);
}
// =============================================================
// =============================================================
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getRowId(int)
*/
//## Java 1.6 begin ##
public
RowId
getRowId
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupported
(
"rowId"
);
checkRegistered
(
parameterIndex
);
return
resultSet
.
getRowId
(
parameterIndex
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getRowId(java.lang.String)
*/
//## Java 1.6 begin ##
public
RowId
getRowId
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
return
getRowId
(
getIndexForName
(
parameterName
)
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setRowId(java.lang.String, java.sql.RowId)
*/
//## Java 1.6 begin ##
public
void
setRowId
(
String
parameterName
,
RowId
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setRowId
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNString(java.lang.String, java.lang.String)
*/
//## Java 1.6 begin ##
public
void
setNString
(
String
parameterName
,
String
value
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
public
void
setNString
(
String
parameterName
,
String
x
)
throws
SQLException
{
setNString
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader, long)
*/
//## Java 1.6 begin ##
public
void
setNCharacterStream
(
String
parameterName
,
Reader
value
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setNCharacterStream
(
String
parameterName
,
Reader
value
,
long
length
)
throws
SQLException
{
setNCharacterStream
(
getIndexForName
(
parameterName
),
value
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNClob(java.lang.String, java.sql.NClob)
*/
//## Java 1.6 begin ##
public
void
setNClob
(
String
parameterName
,
NClob
value
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setNClob
(
String
parameterName
,
NClob
value
)
throws
SQLException
{
setNClob
(
getIndexForName
(
parameterName
),
value
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader, long)
*/
//## Java 1.6 begin ##
public
void
setClob
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setClob
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
setClob
(
getIndexForName
(
parameterName
),
reader
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream, long)
*/
//## Java 1.6 begin ##
public
void
setBlob
(
String
parameterName
,
InputStream
inputStream
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setBlob
(
String
parameterName
,
InputStream
inputStream
,
long
length
)
throws
SQLException
{
setBlob
(
getIndexForName
(
parameterName
),
inputStream
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader, long)
*/
//## Java 1.6 begin ##
public
void
setNClob
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setNClob
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
setNClob
(
getIndexForName
(
parameterName
),
reader
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getNClob(int)
*/
//## Java 1.6 begin ##
public
NClob
getNClob
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getNClob
(
parameterIndex
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getNClob(java.lang.String)
*/
//## Java 1.6 begin ##
public
NClob
getNClob
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedGet
(
);
return
getNClob
(
getIndexForName
(
parameterName
)
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setSQLXML(java.lang.String, java.sql.SQLXML)
*/
//## Java 1.6 begin ##
public
void
setSQLXML
(
String
parameterName
,
SQLXML
xmlObject
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setSQLXML
(
String
parameterName
,
SQLXML
xmlObject
)
throws
SQLException
{
setSQLXML
(
getIndexForName
(
parameterName
),
xmlObject
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getSQLXML(int)
*/
//## Java 1.6 begin ##
public
SQLXML
getSQLXML
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getSQLXML
(
parameterIndex
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getSQLXML(java.lang.String)
*/
//## Java 1.6 begin ##
public
SQLXML
getSQLXML
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedGet
(
);
return
getSQLXML
(
getIndexForName
(
parameterName
)
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getNString(int)
*/
//## Java 1.6 begin ##
public
String
getNString
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getNString
(
parameterIndex
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getNString(java.lang.String)
*/
//## Java 1.6 begin ##
public
String
getNString
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedGet
(
);
return
getNString
(
getIndexForName
(
parameterName
)
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getNCharacterStream(int)
*/
//## Java 1.6 begin ##
public
Reader
getNCharacterStream
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getNCharacterStream
(
parameterIndex
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getNCharacterStream(java.lang.String)
*/
//## Java 1.6 begin ##
public
Reader
getNCharacterStream
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedGet
(
);
return
getNCharacterStream
(
getIndexForName
(
parameterName
)
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getCharacterStream(int)
*/
//## Java 1.6 begin ##
public
Reader
getCharacterStream
(
int
parameterIndex
)
throws
SQLException
{
throw
unsupportedGet
();
checkRegistered
(
parameterIndex
);
return
resultSet
.
getCharacterStream
(
parameterIndex
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#getCharacterStream(java.lang.String)
*/
//## Java 1.6 begin ##
public
Reader
getCharacterStream
(
String
parameterName
)
throws
SQLException
{
throw
unsupportedGet
(
);
return
getCharacterStream
(
getIndexForName
(
parameterName
)
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBlob(java.lang.String, java.sql.Blob)
*/
//## Java 1.6 begin ##
public
void
setBlob
(
String
parameterName
,
Blob
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setBlob
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setClob(java.lang.String, java.sql.Clob)
*/
//## Java 1.6 begin ##
public
void
setClob
(
String
parameterName
,
Clob
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setClob
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream)
*/
//## Java 1.6 begin ##
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
setAsciiStream
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, int)
*/
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setAsciiStream
(
getIndexForName
(
parameterName
),
x
,
length
);
}
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream)
*/
//## Java 1.6 begin ##
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
setBinaryStream
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, long)
*/
//## Java 1.6 begin ##
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
,
long
length
)
throws
SQLException
{
setBinaryStream
(
getIndexForName
(
parameterName
),
x
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream)
*/
//## Java 1.6 begin ##
public
void
setBlob
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setBlob
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
setBlob
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader)
*/
//## Java 1.6 begin ##
public
void
setCharacterStream
(
String
parameterName
,
Reader
x
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setCharacterStream
(
String
parameterName
,
Reader
x
)
throws
SQLException
{
setCharacterStream
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, long)
*/
//## Java 1.6 begin ##
public
void
setCharacterStream
(
String
parameterName
,
Reader
x
,
long
length
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setCharacterStream
(
String
parameterName
,
Reader
x
,
long
length
)
throws
SQLException
{
setCharacterStream
(
getIndexForName
(
parameterName
),
x
,
length
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader)
*/
//## Java 1.6 begin ##
public
void
setClob
(
String
parameterName
,
Reader
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setClob
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
*
[Not supported]
*
@see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader)
*/
//## Java 1.6 begin ##
public
void
setNCharacterStream
(
String
parameterName
,
Reader
x
)
throws
SQLException
{
throw
unsupportedParameterName
();
public
void
setNCharacterStream
(
String
parameterName
,
Reader
x
)
throws
SQLException
{
setNCharacterStream
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
/**
* [Not supported]
* @throws SQLException
* @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader)
*/
//## Java 1.6 begin ##
public
void
setNClob
(
String
parameterName
,
Reader
x
)
throws
SQLException
{
throw
unsupportedParameterName
(
);
setNClob
(
getIndexForName
(
parameterName
),
x
);
}
//## Java 1.6 end ##
private
SQLException
unsupportedParameterName
()
throws
SQLException
{
return
unsupported
(
"parameterName"
);
}
private
SQLException
unsupportedGet
()
throws
SQLException
{
return
unsupported
(
"get"
);
}
}
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
27026f99
...
...
@@ -60,7 +60,7 @@ import java.sql.SQLXML;
public
class
JdbcPreparedStatement
extends
JdbcStatement
implements
PreparedStatement
{
private
final
String
sqlStatement
;
pr
ivate
CommandInterface
command
;
pr
otected
CommandInterface
command
;
private
ArrayList
<
Value
[]>
batchParameters
;
JdbcPreparedStatement
(
JdbcConnection
conn
,
String
sql
,
int
id
,
int
resultSetType
,
...
...
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
27026f99
...
...
@@ -11,8 +11,11 @@ import java.sql.Connection;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
org.h2.test.TestBase
;
import
org.h2.tools.SimpleResultSet
;
/**
* Tests for the CallableStatement class.
...
...
@@ -57,6 +60,56 @@ public class TestCallableStatement extends TestBase {
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertFalse
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS testcall FOR \""
+
getClass
().
getName
()
+
".testCall\""
);
call
=
conn
.
prepareCall
(
"{CALL testcall(?,?,?)}"
);
call
.
setInt
(
"A"
,
100
);
call
.
setString
(
2
,
"abc"
);
long
t
=
System
.
currentTimeMillis
();
call
.
setTimestamp
(
"C"
,
new
Timestamp
(
t
));
call
.
registerOutParameter
(
1
,
Types
.
INTEGER
);
call
.
registerOutParameter
(
"B"
,
Types
.
VARCHAR
);
call
.
executeUpdate
();
try
{
call
.
getTimestamp
(
"C"
);
fail
(
"not registered out parameter accessible"
);
}
catch
(
SQLException
e
)
{
// expected exception
}
call
.
registerOutParameter
(
3
,
Types
.
TIMESTAMP
);
call
.
executeUpdate
();
assertEquals
(
t
+
1
,
call
.
getTimestamp
(
3
).
getTime
());
assertEquals
(
200
,
call
.
getInt
(
"A"
));
assertEquals
(
"ABC"
,
call
.
getString
(
"B"
));
try
{
call
.
getString
(
100
);
fail
(
"incorrect parameter index value"
);
}
catch
(
SQLException
e
)
{
// expected exception
}
try
{
call
.
getString
(
0
);
fail
(
"incorrect parameter index value"
);
}
catch
(
SQLException
e
)
{
// expected exception
}
try
{
call
.
getBoolean
(
"ASD"
);
fail
(
"incorrect parameter name value"
);
}
catch
(
SQLException
e
)
{
// expected exception
}
}
public
static
ResultSet
testCall
(
Connection
connect
,
int
a
,
String
b
,
Timestamp
c
)
throws
SQLException
{
SimpleResultSet
rs
=
new
SimpleResultSet
();
rs
.
addColumn
(
"A"
,
Types
.
INTEGER
,
0
,
0
);
rs
.
addColumn
(
"B"
,
Types
.
VARCHAR
,
0
,
0
);
rs
.
addColumn
(
"C"
,
Types
.
TIMESTAMP
,
0
,
0
);
if
(
"jdbc:columnlist:connection"
.
equals
(
connect
.
getMetaData
().
getURL
()))
{
return
rs
;
}
rs
.
addRow
(
a
*
2
,
b
.
toUpperCase
(),
new
Timestamp
(
c
.
getTime
()
+
1
));
return
rs
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论