This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/master by this push:
new 0cadd0e MPIREDB-362 Bugfix: DBUtils checkStatementParamCount removed
0cadd0e is described below
commit 0cadd0e916e838b007aa3c4e3e5c2bf1396a2153
Author: Rainer Döbele <[email protected]>
AuthorDate: Tue Feb 22 10:42:37 2022 +0100
MPIREDB-362 Bugfix: DBUtils checkStatementParamCount removed
---
.../main/java/org/apache/empire/db/DBUtils.java | 31 ++--------------------
1 file changed, 2 insertions(+), 29 deletions(-)
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
b/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
index 849b101..fa89877 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBUtils.java
@@ -3,7 +3,6 @@ package org.apache.empire.db;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -36,7 +35,6 @@ import org.apache.empire.dbms.DBMSHandler;
import org.apache.empire.exceptions.InternalException;
import org.apache.empire.exceptions.InvalidArgumentException;
import org.apache.empire.exceptions.UnexpectedReturnValueException;
-import org.apache.empire.exceptions.UnspecifiedErrorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,27 +74,6 @@ public class DBUtils implements DBContextAware
{
return context;
}
-
- /**
- * Param count checker
- */
- protected void checkStatementParamCount(String sqlCmd, Object[] sqlParams)
- {
- if (sqlCmd==null || sqlCmd.length()==0)
- throw new InvalidArgumentException("sqlCmd", sqlCmd);
- // count params
- int paramCount = 0;
- int pos = -1;
- while ((pos=sqlCmd.indexOf('?', ++pos))>0)
- paramCount++;
- // check now
- if (paramCount!=(sqlParams!=null ? sqlParams.length : 0))
- { // Wrong number of params
- String msg = MessageFormat.format("Invalid number of parameters
query: provided={0}, required={1}; query="+sqlCmd, paramCount,
sqlParams.length);
- log.error(msg);
- throw new UnspecifiedErrorException(msg);
- }
- }
/**
* Executes an update, insert or delete SQL-Statement.<BR>
@@ -110,9 +87,7 @@ public class DBUtils implements DBContextAware
public int executeSQL(String sqlCmd, Object[] sqlParams,
DBMSHandler.DBSetGenKeys setGenKeys)
{
try
- { // check
- checkStatementParamCount(sqlCmd, sqlParams);
- // Debug
+ { // Debug
if (log.isInfoEnabled())
log.info("Executing: " + sqlCmd);
// execute SQL
@@ -152,9 +127,7 @@ public class DBUtils implements DBContextAware
public ResultSet executeQuery(String sqlCmd, Object[] sqlParams, boolean
scrollable)
{
try
- { // check
- checkStatementParamCount(sqlCmd, sqlParams);
- // Debug
+ { // Debug
if (log.isDebugEnabled())
log.debug("Executing: " + sqlCmd);
// Execute the Statement