提交 d954cd03 authored 作者: Thomas Mueller's avatar Thomas Mueller

Calling execute() or prepareStatement() with null

上级 bad2c71f
...@@ -1111,13 +1111,32 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1111,13 +1111,32 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
/** /**
* Convert JDBC escape sequences in the SQL statement. * Convert JDBC escape sequences in the SQL statement. This
* method throws an exception if the SQL statement is null.
* *
* @param sql the SQL statement with or without JDBC escape sequences * @param sql the SQL statement with or without JDBC escape sequences
* @return the SQL statement without JDBC escape sequences * @return the SQL statement without JDBC escape sequences
*/ */
String translateSQL(String sql) throws SQLException { private String translateSQL(String sql) throws SQLException {
if (sql == null || sql.indexOf('{') < 0) { return translateSQL(sql, true);
}
/**
* Convert JDBC escape sequences in the SQL statement if required. This
* method throws an exception if the SQL statement is null.
*
* @param sql the SQL statement with or without JDBC escape sequences
* @param escapeProcessing whether escape sequences should be replaced
* @return the SQL statement without JDBC escape sequences
*/
String translateSQL(String sql, boolean escapeProcessing) throws SQLException {
if (sql == null) {
throw Message.getInvalidValueException(sql, "SQL");
}
if (!escapeProcessing) {
return sql;
}
if (sql.indexOf('{') < 0) {
return sql; return sql;
} }
int len = sql.length(); int len = sql.length();
......
...@@ -63,9 +63,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -63,9 +63,7 @@ public class JdbcStatement extends TraceObject implements Statement {
} }
checkClosed(); checkClosed();
closeOldResultSet(); closeOldResultSet();
if (escapeProcessing) { sql = conn.translateSQL(sql, escapeProcessing);
sql = conn.translateSQL(sql);
}
synchronized (session) { synchronized (session) {
CommandInterface command = conn.prepareCommand(sql, fetchSize); CommandInterface command = conn.prepareCommand(sql, fetchSize);
ResultInterface result; ResultInterface result;
...@@ -107,9 +105,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -107,9 +105,7 @@ public class JdbcStatement extends TraceObject implements Statement {
debugCodeCall("executeUpdate", sql); debugCodeCall("executeUpdate", sql);
checkClosedForWrite(); checkClosedForWrite();
closeOldResultSet(); closeOldResultSet();
if (escapeProcessing) { sql = conn.translateSQL(sql, escapeProcessing);
sql = conn.translateSQL(sql);
}
CommandInterface command = conn.prepareCommand(sql, fetchSize); CommandInterface command = conn.prepareCommand(sql, fetchSize);
synchronized (session) { synchronized (session) {
setExecutingStatement(command); setExecutingStatement(command);
...@@ -146,9 +142,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -146,9 +142,7 @@ public class JdbcStatement extends TraceObject implements Statement {
} }
checkClosedForWrite(); checkClosedForWrite();
closeOldResultSet(); closeOldResultSet();
if (escapeProcessing) { sql = conn.translateSQL(sql, escapeProcessing);
sql = conn.translateSQL(sql);
}
CommandInterface command = conn.prepareCommand(sql, fetchSize); CommandInterface command = conn.prepareCommand(sql, fetchSize);
boolean returnsResultSet; boolean returnsResultSet;
synchronized (session) { synchronized (session) {
...@@ -577,9 +571,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -577,9 +571,7 @@ public class JdbcStatement extends TraceObject implements Statement {
try { try {
debugCodeCall("addBatch", sql); debugCodeCall("addBatch", sql);
checkClosed(); checkClosed();
if (escapeProcessing) { sql = conn.translateSQL(sql, escapeProcessing);
sql = conn.translateSQL(sql);
}
if (batchCommands == null) { if (batchCommands == null) {
batchCommands = new ObjectArray(); batchCommands = new ObjectArray();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论