Class StreamingResult

java.lang.Object
org.mariadb.jdbc.client.result.Result
org.mariadb.jdbc.client.result.StreamingResult
All Implemented Interfaces:
AutoCloseable, ResultSet, Wrapper, Completion, ServerMessage

public class StreamingResult extends Result
Streaming result-set implementation. Implementation rely on reading as many rows than fetch size required, keeping remaining rows in TCP-IP buffer

The server usually expects clients to read off the result set relatively quickly. The net_write_timeout server variable controls this behavior (defaults to 60s).

If you don't expect results to be handled in this amount of time there is a different possibility:

  • With > MariaDB server, you can use the query "SET STATEMENT net_write_timeout=10000 FOR XXX" with XXX your "normal" query. This will indicate that specifically for this query, net_write_timeout will be set to a longer time (10000 in this example).
  • for non mariadb servers, a specific query will have to temporarily set net_write_timeout ("SET STATEMENT net_write_timeout=..."), and set it back afterward.
  • if your application usually uses a lot of long queries with fetch size, the connection can be set using option "sessionVariables=net_write_timeout=xxx"

Even using setFetchSize, the server will send all results to the client.

If another query is executed on the same connection when a streaming result-set has not been fully read, the connector will put the whole remaining streaming result-set in memory in order to execute the next query. This can lead to OutOfMemoryError if not handled.