Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2e80129d
提交
2e80129d
authored
11月 12, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CallableStatement: now the syntax "{? = CALL...}" is supported as well.
上级
9c32f47a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
53 行增加
和
6 行删除
+53
-6
Parser.java
h2/src/main/org/h2/command/Parser.java
+10
-0
JdbcCallableStatement.java
h2/src/main/org/h2/jdbc/JdbcCallableStatement.java
+23
-0
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+4
-4
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+14
-0
TestNativeSQL.java
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
2e80129d
...
...
@@ -138,6 +138,7 @@ import org.h2.value.ValueDate;
import
org.h2.value.ValueDecimal
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueString
;
import
org.h2.value.ValueTime
;
import
org.h2.value.ValueTimestamp
;
...
...
@@ -283,6 +284,15 @@ public class Parser {
}
else
{
char
first
=
token
.
charAt
(
0
);
switch
(
first
)
{
case
'?'
:
// read the ? as a parameter
readTerm
();
// this is an 'out' parameter - set a dummy value
parameters
.
get
(
0
).
setValue
(
ValueNull
.
INSTANCE
);
read
(
"="
);
read
(
"CALL"
);
c
=
parseCall
();
break
;
case
'('
:
c
=
parseSelect
();
break
;
...
...
h2/src/main/org/h2/jdbc/JdbcCallableStatement.java
浏览文件 @
2e80129d
...
...
@@ -53,6 +53,29 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call
setTrace
(
session
.
getTrace
(),
TraceObject
.
CALLABLE_STATEMENT
,
id
);
}
/**
* Executes an arbitrary statement. If another result set exists for this
* statement, this will be closed (even if this statement fails). If auto
* commit is on, and the statement is not a select, this statement will be
* committed.
*
* @return true if a result set is available, false if not
* @throws SQLException if this object is closed or invalid
*/
public
boolean
execute
()
throws
SQLException
{
try
{
checkClosed
();
if
(
command
.
isQuery
())
{
super
.
executeQuery
().
next
();
return
true
;
}
super
.
executeUpdate
();
return
false
;
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
/**
* Executes a statement (insert, update, delete, create, drop)
* and returns the update count.
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
2e80129d
...
...
@@ -1195,7 +1195,7 @@ public class JdbcConnection extends TraceObject implements Connection {
level
--;
break
;
}
else
if
(
chars
[
i
]
==
'?'
)
{
chars
[
i
++]
=
' '
;
i
++
;
checkRunOver
(
i
,
len
,
sql
);
while
(
Character
.
isSpaceChar
(
chars
[
i
]))
{
i
++;
...
...
@@ -1204,7 +1204,7 @@ public class JdbcConnection extends TraceObject implements Connection {
if
(
sql
.
charAt
(
i
)
!=
'='
)
{
throw
DbException
.
getSyntaxError
(
sql
,
i
,
"="
);
}
chars
[
i
++]
=
' '
;
i
++
;
checkRunOver
(
i
,
len
,
sql
);
while
(
Character
.
isSpaceChar
(
chars
[
i
]))
{
i
++;
...
...
@@ -1368,11 +1368,11 @@ public class JdbcConnection extends TraceObject implements Connection {
return
;
}
if
(
session
!=
null
&&
openStackTrace
!=
null
)
{
trace
.
error
(
"Connection not closed"
,
openStackTrace
);
trace
.
error
(
openStackTrace
,
"connection not closed"
);
try
{
close
();
}
catch
(
SQLException
e
)
{
trace
.
debug
(
"finalize"
,
e
);
trace
.
debug
(
e
,
"finalize"
);
}
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
2e80129d
...
...
@@ -35,11 +35,25 @@ public class TestCallableStatement extends TestBase {
public
void
test
()
throws
SQLException
{
deleteDb
(
"callableStatement"
);
Connection
conn
=
getConnection
(
"callableStatement"
);
testCallWithResult
(
conn
);
testPrepare
(
conn
);
conn
.
close
();
deleteDb
(
"callableStatement"
);
}
private
void
testCallWithResult
(
Connection
conn
)
throws
SQLException
{
CallableStatement
call
;
for
(
String
s
:
new
String
[]{
"{?= call abs(?)}"
,
" { ? = call abs(?)}"
,
" {? = call abs(?)}"
})
{
call
=
conn
.
prepareCall
(
s
);
call
.
setInt
(
2
,
-
3
);
call
.
registerOutParameter
(
1
,
Types
.
INTEGER
);
call
.
execute
();
assertEquals
(
3
,
call
.
getInt
(
1
));
call
.
executeUpdate
();
assertEquals
(
3
,
call
.
getInt
(
1
));
}
}
private
void
testPrepare
(
Connection
conn
)
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
CallableStatement
call
;
...
...
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
浏览文件 @
2e80129d
...
...
@@ -47,9 +47,9 @@ public class TestNativeSQL extends TestBase {
"{call TEST('}')}"
,
" call TEST('}') "
,
"{?= call TEST('}')}"
,
"
call TEST('}') "
,
"{?= call TEST('}')}"
,
"
?=
call TEST('}') "
,
"{? = call TEST('}')}"
,
"
call TEST('}') "
,
"{? = call TEST('}')}"
,
"
? =
call TEST('}') "
,
"{{{{this is a bug}"
,
null
,
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论