Clear statement parameters before new call.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / aa / attrresolv / provider / JDBCDataConnector.java
index dfc91de..928a721 100644 (file)
@@ -307,7 +307,7 @@ public class JDBCDataConnector extends BaseDataConnector implements DataConnecto
                        conn = dataSource.getConnection();
                        log.debug("Connection retrieved from pool");
                } catch (Exception e) {
-                       log.error("Unable to fetch a connection from the pool");
+                       log.error("JDBC Connector (" + getId() + ") unable to fetch a connection from the pool");
                        throw new ResolutionPlugInException("Unable to fetch a connection from the pool: " + e.getMessage());
                }
                if (conn == null) {
@@ -320,6 +320,7 @@ public class JDBCDataConnector extends BaseDataConnector implements DataConnecto
                PreparedStatement preparedStatement = null;
                try {
                        preparedStatement = conn.prepareStatement(searchVal);
+            preparedStatement.clearParameters();
                        statementCreator.create(preparedStatement, principal, requester, depends);
                        rs = preparedStatement.executeQuery();
                        if (!rs.next()) {
@@ -649,8 +650,8 @@ class DependencyStatementCreator implements JDBCStatementCreator {
                        }
 
                } catch (Exception e) {
-                       log.error("Encountered an error while creating prepared statement: " + e);
-                       throw new JDBCStatementCreatorException(
+                       log.error("Encountered an error while creating prepared statement (principal=" + principal.getName() + "): " + e);
+                        throw new JDBCStatementCreatorException(
                                "Encountered an error while creating prepared statement: " + e.getMessage());
                }
        }