Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
65cf4260
提交
65cf4260
authored
11月 20, 2009
作者:
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
...
@@ -576,9 +576,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
void
setRef
(
int
parameterIndex
,
Ref
x
)
throws
SQLException
{
public
void
setRef
(
int
parameterIndex
,
Ref
x
)
throws
SQLException
{
try
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setRef("
+
parameterIndex
+
", x);"
);
debugCode
(
"setRef("
+
parameterIndex
+
", x);"
);
}
throw
Message
.
getUnsupportedException
(
"ref"
);
throw
Message
.
getUnsupportedException
(
"ref"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -663,9 +661,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -663,9 +661,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
void
setUnicodeStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
public
void
setUnicodeStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
try
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setUnicodeStream("
+
parameterIndex
+
", x, "
+
length
+
");"
);
debugCode
(
"setUnicodeStream("
+
parameterIndex
+
", x, "
+
length
+
");"
);
}
throw
Message
.
getUnsupportedException
(
"unicodeStream"
);
throw
Message
.
getUnsupportedException
(
"unicodeStream"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -795,9 +791,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -795,9 +791,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
void
setArray
(
int
parameterIndex
,
Array
x
)
throws
SQLException
{
public
void
setArray
(
int
parameterIndex
,
Array
x
)
throws
SQLException
{
try
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setArray("
+
parameterIndex
+
", x);"
);
debugCode
(
"setArray("
+
parameterIndex
+
", x);"
);
}
throw
Message
.
getUnsupportedException
(
"setArray"
);
throw
Message
.
getUnsupportedException
(
"setArray"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -978,9 +972,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -978,9 +972,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
void
setURL
(
int
parameterIndex
,
URL
x
)
throws
SQLException
{
public
void
setURL
(
int
parameterIndex
,
URL
x
)
throws
SQLException
{
try
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"setURL("
+
parameterIndex
+
", x);"
);
debugCode
(
"setURL("
+
parameterIndex
+
", x);"
);
}
throw
Message
.
getUnsupportedException
(
"url"
);
throw
Message
.
getUnsupportedException
(
"url"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1127,9 +1119,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -1127,9 +1119,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
try
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
}
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1144,9 +1134,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -1144,9 +1134,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
try
{
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
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1160,9 +1148,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -1160,9 +1148,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
try
{
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
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1176,9 +1162,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -1176,9 +1162,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
try
{
try
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
autoGeneratedKeys
+
");"
);
debugCode
(
"execute("
+
quote
(
sql
)
+
", "
+
autoGeneratedKeys
+
");"
);
}
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1192,9 +1176,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -1192,9 +1176,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
try
{
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
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1208,9 +1190,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -1208,9 +1190,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*/
*/
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
try
{
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
);
throw
Message
.
getSQLException
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
...
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
65cf4260
...
@@ -106,25 +106,29 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -106,25 +106,29 @@ public class JdbcStatement extends TraceObject implements Statement {
public
int
executeUpdate
(
String
sql
)
throws
SQLException
{
public
int
executeUpdate
(
String
sql
)
throws
SQLException
{
try
{
try
{
debugCodeCall
(
"executeUpdate"
,
sql
);
debugCodeCall
(
"executeUpdate"
,
sql
);
checkClosedForWrite
();
return
executeUpdateInternal
(
sql
);
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
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
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
* Executes an arbitrary statement. If another result set exists for this
* statement, this will be closed (even if this statement fails).
* statement, this will be closed (even if this statement fails).
...
@@ -139,39 +143,41 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -139,39 +143,41 @@ public class JdbcStatement extends TraceObject implements Statement {
*/
*/
public
boolean
execute
(
String
sql
)
throws
SQLException
{
public
boolean
execute
(
String
sql
)
throws
SQLException
{
try
{
try
{
int
id
=
getNextId
(
TraceObject
.
RESULT_SET
);
debugCodeCall
(
"execute"
,
sql
);
if
(
isDebugEnabled
())
{
return
executeInternal
(
sql
);
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
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
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.
* Returns the last result set produces by this statement.
*
*
...
@@ -610,7 +616,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -610,7 +616,7 @@ public class JdbcStatement extends TraceObject implements Statement {
for
(
int
i
=
0
;
i
<
batchCommands
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
batchCommands
.
size
();
i
++)
{
String
sql
=
batchCommands
.
get
(
i
);
String
sql
=
batchCommands
.
get
(
i
);
try
{
try
{
result
[
i
]
=
executeUpdate
(
sql
);
result
[
i
]
=
executeUpdate
Internal
(
sql
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
logAndConvert
(
e
);
logAndConvert
(
e
);
//## Java 1.4 begin ##
//## Java 1.4 begin ##
...
@@ -698,7 +704,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -698,7 +704,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
}
}
return
executeUpdate
(
sql
);
return
executeUpdate
Internal
(
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -720,7 +726,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -720,7 +726,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
quoteIntArray
(
columnIndexes
)+
");"
);
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
quoteIntArray
(
columnIndexes
)+
");"
);
}
}
return
executeUpdate
(
sql
);
return
executeUpdate
Internal
(
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -742,7 +748,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -742,7 +748,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
quoteArray
(
columnNames
)+
");"
);
debugCode
(
"executeUpdate("
+
quote
(
sql
)+
", "
+
quoteArray
(
columnNames
)+
");"
);
}
}
return
executeUpdate
(
sql
);
return
executeUpdate
Internal
(
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -764,7 +770,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -764,7 +770,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
autoGeneratedKeys
+
");"
);
}
}
return
execute
(
sql
);
return
execute
Internal
(
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -786,7 +792,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -786,7 +792,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
quoteIntArray
(
columnIndexes
)+
");"
);
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
quoteIntArray
(
columnIndexes
)+
");"
);
}
}
return
execute
(
sql
);
return
execute
Internal
(
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -808,7 +814,7 @@ public class JdbcStatement extends TraceObject implements Statement {
...
@@ -808,7 +814,7 @@ public class JdbcStatement extends TraceObject implements Statement {
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
quoteArray
(
columnNames
)+
");"
);
debugCode
(
"execute("
+
quote
(
sql
)+
", "
+
quoteArray
(
columnNames
)+
");"
);
}
}
return
execute
(
sql
);
return
execute
Internal
(
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论