Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
65cf4260
提交
65cf4260
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 138: the trace output of Statement.execute(String, int) and executeUpdate was incorrect.
上级
5fb0c18e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
65 行增加
和
79 行删除
+65
-79
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+10
-30
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+55
-49
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
65cf4260
...
...
@@ -576,9 +576,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
void
setRef
(
int
parameterIndex
,
Ref
x
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setRef("
+
parameterIndex
+
", x);"
);
}
debugCode
(
"setRef("
+
parameterIndex
+
", x);"
);
throw
Message
.
getUnsupportedException
(
"ref"
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -663,9 +661,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
void
setUnicodeStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setUnicodeStream("
+
parameterIndex
+
", x, "
+
length
+
");"
);
}
debugCode
(
"setUnicodeStream("
+
parameterIndex
+
", x, "
+
length
+
");"
);
throw
Message
.
getUnsupportedException
(
"unicodeStream"
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -795,9 +791,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
void
setArray
(
int
parameterIndex
,
Array
x
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setArray("
+
parameterIndex
+
", x);"
);
}
debugCode
(
"setArray("
+
parameterIndex
+
", x);"
);
throw
Message
.
getUnsupportedException
(
"setArray"
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -978,9 +972,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
void
setURL
(
int
parameterIndex
,
URL
x
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setURL("
+
parameterIndex
+
", x);"
);
}
debugCode
(
"setURL("
+
parameterIndex
+
", x);"
);
throw
Message
.
getUnsupportedException
(
"url"
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -1127,9 +1119,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
}
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -1144,9 +1134,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)
+
", "
+
quoteIntArray
(
columnIndexes
)
+
");"
);
}
debugCode
(
"executeUpdate("
+
quote
(
sql
)
+
", "
+
quoteIntArray
(
columnIndexes
)
+
");"
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -1160,9 +1148,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)
+
", "
+
quoteArray
(
columnNames
)
+
");"
);
}
debugCode
(
"executeUpdate("
+
quote
(
sql
)
+
", "
+
quoteArray
(
columnNames
)
+
");"
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -1176,9 +1162,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
autoGeneratedKeys
+
");"
);
}
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
autoGeneratedKeys
+
");"
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -1192,9 +1176,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
quoteIntArray
(
columnIndexes
)
+
");"
);
}
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
quoteIntArray
(
columnIndexes
)
+
");"
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
@@ -1208,9 +1190,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
quoteArray
(
columnNames
)
+
");"
);
}
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
quoteArray
(
columnNames
)
+
");"
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
65cf4260
...
...
@@ -106,25 +106,29 @@ public class JdbcStatement extends TraceObject implements Statement {
public
int
executeUpdate
(
String
sql
)
throws
SQLException
{
try
{
debugCodeCall
(
"executeUpdate"
,
sql
);
checkClosedForWrite
();
closeOldResultSet
();
sql
=
conn
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
synchronized
(
session
)
{
setExecutingStatement
(
command
);
try
{
updateCount
=
command
.
executeUpdate
();
}
finally
{
setExecutingStatement
(
null
);
}
}
command
.
close
();
return
updateCount
;
return
executeUpdateInternal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
private
int
executeUpdateInternal
(
String
sql
)
throws
SQLException
{
checkClosedForWrite
();
closeOldResultSet
();
sql
=
conn
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
synchronized
(
session
)
{
setExecutingStatement
(
command
);
try
{
updateCount
=
command
.
executeUpdate
();
}
finally
{
setExecutingStatement
(
null
);
}
}
command
.
close
();
return
updateCount
;
}
/**
* Executes an arbitrary statement. If another result set exists for this
* statement, this will be closed (even if this statement fails).
...
...
@@ -139,39 +143,41 @@ public class JdbcStatement extends TraceObject implements Statement {
*/
public
boolean
execute
(
String
sql
)
throws
SQLException
{
try
{
int
id
=
getNextId
(
TraceObject
.
RESULT_SET
);
if
(
isDebugEnabled
())
{
debugCodeCall
(
"execute"
,
sql
);
}
checkClosedForWrite
();
closeOldResultSet
();
sql
=
conn
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
boolean
returnsResultSet
;
synchronized
(
session
)
{
setExecutingStatement
(
command
);
try
{
if
(
command
.
isQuery
())
{
returnsResultSet
=
true
;
boolean
scrollable
=
resultSetType
!=
ResultSet
.
TYPE_FORWARD_ONLY
;
boolean
updatable
=
resultSetConcurrency
==
ResultSet
.
CONCUR_UPDATABLE
;
ResultInterface
result
=
command
.
executeQuery
(
maxRows
,
scrollable
);
resultSet
=
new
JdbcResultSet
(
conn
,
this
,
result
,
id
,
closedByResultSet
,
scrollable
,
updatable
);
}
else
{
returnsResultSet
=
false
;
updateCount
=
command
.
executeUpdate
();
}
}
finally
{
setExecutingStatement
(
null
);
}
}
command
.
close
();
return
returnsResultSet
;
debugCodeCall
(
"execute"
,
sql
);
return
executeInternal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
}
private
boolean
executeInternal
(
String
sql
)
throws
SQLException
{
int
id
=
getNextId
(
TraceObject
.
RESULT_SET
);
checkClosedForWrite
();
closeOldResultSet
();
sql
=
conn
.
translateSQL
(
sql
,
escapeProcessing
);
CommandInterface
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
boolean
returnsResultSet
;
synchronized
(
session
)
{
setExecutingStatement
(
command
);
try
{
if
(
command
.
isQuery
())
{
returnsResultSet
=
true
;
boolean
scrollable
=
resultSetType
!=
ResultSet
.
TYPE_FORWARD_ONLY
;
boolean
updatable
=
resultSetConcurrency
==
ResultSet
.
CONCUR_UPDATABLE
;
ResultInterface
result
=
command
.
executeQuery
(
maxRows
,
scrollable
);
resultSet
=
new
JdbcResultSet
(
conn
,
this
,
result
,
id
,
closedByResultSet
,
scrollable
,
updatable
);
}
else
{
returnsResultSet
=
false
;
updateCount
=
command
.
executeUpdate
();
}
}
finally
{
setExecutingStatement
(
null
);
}
}
command
.
close
();
return
returnsResultSet
;
}
/**
* Returns the last result set produces by this statement.
*
...
...
@@ -610,7 +616,7 @@ public class JdbcStatement extends TraceObject implements Statement {
for
(
int
i
=
0
;
i
<
batchCommands
.
size
();
i
++)
{
String
sql
=
batchCommands
.
get
(
i
);
try
{
result
[
i
]
=
executeUpdate
(
sql
);
result
[
i
]
=
executeUpdate
Internal
(
sql
);
}
catch
(
SQLException
e
)
{
logAndConvert
(
e
);
//## Java 1.4 begin ##
...
...
@@ -698,7 +704,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
}
return
executeUpdate
(
sql
);
return
executeUpdate
Internal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -720,7 +726,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
quoteIntArray
(
columnIndexes
)+
");"
);
}
return
executeUpdate
(
sql
);
return
executeUpdate
Internal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -742,7 +748,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
quoteArray
(
columnNames
)+
");"
);
}
return
executeUpdate
(
sql
);
return
executeUpdate
Internal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -764,7 +770,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
}
return
execute
(
sql
);
return
execute
Internal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -786,7 +792,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
quoteIntArray
(
columnIndexes
)+
");"
);
}
return
execute
(
sql
);
return
execute
Internal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -808,7 +814,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
quoteArray
(
columnNames
)+
");"
);
}
return
execute
(
sql
);
return
execute
Internal
(
sql
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论