Constructor.
Parameters: p - the predicate Parameters: queryResult - the result set Parameters: c - the cache list to collect facts - if null, nothing will be cached Parameters: closeConnection - whether to close the connection at the end Parameters: con - the connection used