private static void loadWaitEventsForSQLStatements(List<DeltaSQLStatementSnapshot> sqlStatementsToLoad,
                                                       Calendar startTime, Calendar stopTime,
                                                       Map<DeltaSQLStatementSnapshot, List<WaitEventForStatementTuple>> result) {

        Connection connection = null;
        try {
            connection = ConnectionPoolUtils.getConnectionFromPool();
            PreparedStatement sqlWaitEventsStatement = connection
                    .prepareStatement(SELECT_WAIT_EVENTS_FOR_100_STATEMENTS);
            sqlWaitEventsStatement.setFetchSize(1000);

            int indexPlaceholder = 1;
            for (DeltaSQLStatementSnapshot currentStatement : sqlStatementsToLoad) {
                sqlWaitEventsStatement.setString(indexPlaceholder,
                        currentStatement.getSqlStatement().getSqlId());
                indexPlaceholder++;

                if (indexPlaceholder > NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL) {
                    // set the time window for the samples
                    sqlWaitEventsStatement.setDate(NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL + 1, new java.sql.Date(startTime.getTimeInMillis()));
                    sqlWaitEventsStatement.setDate(NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL + 2, new java.sql.Date(stopTime.getTimeInMillis()));

                    // all place holders are filled - so fetch the wait events from the DB
                    getWaitEventsFromDB(sqlStatementsToLoad, sqlWaitEventsStatement, result);

                    indexPlaceholder = 1;
                }
            }

            if (indexPlaceholder > 1) {
                // there are some statements left...
                // fill the empty bind variables with invalid addresses
                for (int index = indexPlaceholder; index <= NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL; index++) {
                    sqlWaitEventsStatement.setString(index, "");
                }

                // set the time window for the samples
                sqlWaitEventsStatement.setDate(NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL + 1, new java.sql.Date(startTime.getTimeInMillis()));
                sqlWaitEventsStatement.setDate(NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL + 2, new java.sql.Date(stopTime.getTimeInMillis()));

                getWaitEventsFromDB(sqlStatementsToLoad, sqlWaitEventsStatement, result);
            }
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, e);
        } finally {
            ConnectionPoolUtils.returnConnectionToPool(connection);
        }
    }