JDBC Driver - PolyStatement

org.polypheny.jdbc.multimodel.PolyStatement executes a statement in a named query language. Create one with PolyConnection.createPolyStatement().

execute

execute(String namespaceName, String languageName, String statement) sends the statement text to Prism and returns a Result.

Argument Meaning
namespaceName Namespace in which the server executes the statement. Pass null to use the session’s current namespace.
languageName Use sql for SQL, mongo for MongoQL, or cypher for Cypher.
statement Query or command in that language. Use JDBC PreparedStatement for SQL values that must be bound as parameters.

The method can throw PrismInterfaceServiceException, a subclass of SQLException. It sends the text as an unparameterized Prism statement.

Lifecycle and accessors

  • PolyStatement(PolyConnection) creates a statement bound to the given connection. The connection’s factory uses this constructor.
  • getConnection() returns the owning PolyConnection.
  • getStatementId() exposes the ID of the Prism statement. It is used when fetching additional result frames.

Reusing the object via execute releases the previous server statement and replaces its ID. Consume each result before reusing the statement. PolyStatement implements AutoCloseable. Use try-with-resources to release the server statement and its result, including when you stop iteration early.

Page size

Call setFetchSize(int) before executing a query to request the page size. Pass a positive size, or pass 0 to restore the driver default. getFetchSize() returns the current setting. Iterating a result fetches additional pages as needed. Keep the statement and connection open while reading them.

See the MongoQL example and the Cypher example.

Request timeouts

Connection.setNetworkTimeout(executor, milliseconds) bounds the wait for a complete Prism response, including when the server sends a statement ID first. A timeout of 0 waits indefinitely. If a request times out or the calling thread is interrupted while waiting for its response, the driver closes the connection.

If fetching a result page fails, the iterator reports an IllegalStateException. Fetched items remain readable. Iteration reports the same error at the failed page.

© Polypheny GmbH. All Rights Reserved.