Source:
public static void udpateUserRoleMappingInBatchModeForInternalRoles(Connection dbConnection, String sqlStmt, String primaryDomain, Object... params) throws UserStoreException { boolean localConnection = false; try (PreparedStatement prepStmt = dbConnection.prepareStatement(sqlStmt)) { int batchParamIndex = -1; if (params != null && params.length > 0) { for (int i = 0; i < params.length; i++) { Object param = params[i]; if (param == null) { throw new UserStoreException("Null data provided."); } else if (param instanceof String[]) { batchParamIndex = i; } else if (param instanceof String) { prepStmt.setString(i + 1, (String) param); } else if (param instanceof Integer) { prepStmt.setInt(i + 1, (Integer) param); } } } if (batchParamIndex != -1) { String[] values = (String[]) params[batchParamIndex]; for (String value : values) { String strParam = (String) value; strParam = UserCoreUtil.addDomainToName(strParam, primaryDomain); String domainParam = UserCoreUtil.extractDomainFromName(strParam); if (domainParam != null) { domainParam = domainParam.toUpperCase(); } prepStmt.setString(params.length + 1, domainParam); String nameWithoutDomain = UserCoreUtil.removeDomainFromName(strParam); prepStmt.setString(batchParamIndex + 1, nameWithoutDomain); prepStmt.addBatch(); } } int[] count = prepStmt.executeBatch(); if (log.isDebugEnabled()) { log.debug("Executed a batch update. Query is : " + sqlStmt + ": and result is" + Arrays.toString(count)); } if (localConnection) { dbConnection.commit(); } } catch (SQLException e) { String errorMessage = "Using sql : " + sqlStmt + " " + e.getMessage(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { close(dbConnection); } }

Target:
public static void udpateUserRoleMappingInBatchModeForInternalRoles(Connection dbConnection, String sqlStmt, String primaryDomain, Object... params) throws UserStoreException { boolean localConnection = false; try (PreparedStatement prepStmt = dbConnection.prepareStatement(sqlStmt)) { int batchParamIndex = -1; if (params != null && params.length > 0) { for (int i = 0; i < params.length; i++) { Object param = params[i]; if (param == null) { throw new UserStoreException("Null data provided."); } else if (param instanceof String[]) { batchParamIndex = i; } else if (param instanceof String) { prepStmt.setString(i + 1, (String) param); } else if (param instanceof Integer) { prepStmt.setInt(i + 1, (Integer) param); } } } if (batchParamIndex != -1) { String[] values = (String[]) params[batchParamIndex]; for (String value : values) { String strParam = (String) value; strParam = UserCoreUtil.addDomainToName(strParam, primaryDomain); String domainParam = UserCoreUtil.extractDomainFromName(strParam); if (domainParam != null) { domainParam = domainParam.toUpperCase(); } prepStmt.setString(params.length + 1, domainParam); String nameWithoutDomain = UserCoreUtil.removeDomainFromName(strParam); prepStmt.setString(batchParamIndex + 1, nameWithoutDomain); prepStmt.addBatch(); } } int[] count = prepStmt.executeBatch(); if (log.isDebugEnabled()) { log.debug("Executed a batch update. Query is : " + sqlStmt + ": and result is" + Arrays.toString(count)); } if (localConnection) { dbConnection.commit(); } } catch (SQLException e) { String errorMessage = "Using sql : " + sqlStmt + " " + e.getMessage(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { if(localConnection) { close(dbConnection); } } }