提交 65cf4260 authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 138: the trace output of Statement.execute(String, int) and executeUpdate was incorrect.

上级 5fb0c18e
......@@ -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);");
}
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+");");
}
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);");
}
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);");
}
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+");");
}
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) + ");");
}
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) + ");");
}
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 + ");");
}
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) + ");");
}
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) + ");");
}
throw Message.getSQLException(ErrorCode.METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT);
} catch (Exception e) {
throw logAndConvert(e);
......
......@@ -106,6 +106,13 @@ public class JdbcStatement extends TraceObject implements Statement {
public int executeUpdate(String sql) throws SQLException {
try {
debugCodeCall("executeUpdate", sql);
return executeUpdateInternal(sql);
} catch (Exception e) {
throw logAndConvert(e);
}
}
private int executeUpdateInternal(String sql) throws SQLException {
checkClosedForWrite();
closeOldResultSet();
sql = conn.translateSQL(sql, escapeProcessing);
......@@ -120,9 +127,6 @@ public class JdbcStatement extends TraceObject implements Statement {
}
command.close();
return updateCount;
} catch (Exception e) {
throw logAndConvert(e);
}
}
/**
......@@ -139,10 +143,15 @@ 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);
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);
......@@ -167,9 +176,6 @@ public class JdbcStatement extends TraceObject implements Statement {
}
command.close();
return returnsResultSet;
} catch (Exception e) {
throw logAndConvert(e);
}
}
/**
......@@ -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] = executeUpdateInternal(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 executeUpdateInternal(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 executeUpdateInternal(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 executeUpdateInternal(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 executeInternal(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 executeInternal(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 executeInternal(sql);
} catch (Exception e) {
throw logAndConvert(e);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论