Queries That Run Forever

A conventional SQL application prepares and executes a statement with a SELECT… query and iterates through the returned result set until end of fetch is detected, when there are no more rows to return. The application then returns to doing something else. In the SQLstream context of streaming data and queries that run forever, there is no obvious “end of fetch”. Instead, the “get next row” call (i.e., ResultSet.next() for JDBC) blocks within the SQLstream client driver until one of the following two possibilities occurs:

  • The next row becomes available, which could be a very long wait for some data sources, or
  • The statement is deliberately closed by the client application*.

In the latter case, the application is in effect “un-subscribing” from the stream. For more detailed discussion of preventing blocking, see the topic JDBC driver in the SQLstream s-Server Integration Guide. SQLstream extends the JDBC API to offer millisecond-granularity timeout intervals to make ResultSet polling more practical for an application that wants to remain responsive to other events.