提交 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 {
}
/**
* 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
* @return the SQL statement without JDBC escape sequences
*/
String translateSQL(String sql) throws SQLException {
if (sql == null || sql.indexOf('{') < 0) {
private String translateSQL(String sql) throws SQLException {
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;
}
int len = sql.length();
......
......@@ -63,9 +63,7 @@ public class JdbcStatement extends TraceObject implements Statement {
}
checkClosed();
closeOldResultSet();
if (escapeProcessing) {
sql = conn.translateSQL(sql);
}
sql = conn.translateSQL(sql, escapeProcessing);
synchronized (session) {
CommandInterface command = conn.prepareCommand(sql, fetchSize);
ResultInterface result;
......@@ -107,9 +105,7 @@ public class JdbcStatement extends TraceObject implements Statement {
debugCodeCall("executeUpdate", sql);
checkClosedForWrite();
closeOldResultSet();
if (escapeProcessing) {
sql = conn.translateSQL(sql);
}
sql = conn.translateSQL(sql, escapeProcessing);
CommandInterface command = conn.prepareCommand(sql, fetchSize);
synchronized (session) {
setExecutingStatement(command);
......@@ -146,9 +142,7 @@ public class JdbcStatement extends TraceObject implements Statement {
}
checkClosedForWrite();
closeOldResultSet();
if (escapeProcessing) {
sql = conn.translateSQL(sql);
}
sql = conn.translateSQL(sql, escapeProcessing);
CommandInterface command = conn.prepareCommand(sql, fetchSize);
boolean returnsResultSet;
synchronized (session) {
......@@ -577,9 +571,7 @@ public class JdbcStatement extends TraceObject implements Statement {
try {
debugCodeCall("addBatch", sql);
checkClosed();
if (escapeProcessing) {
sql = conn.translateSQL(sql);
}
sql = conn.translateSQL(sql, escapeProcessing);
if (batchCommands == null) {
batchCommands = new ObjectArray();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论