JDBC Driver - Multimodel Extension

The Polypheny JDBC driver exposes extensions for working with more than one data model over the same Prism connection. For conventional SQL applications, use java.sql.Connection, PreparedStatement, and ResultSet. Use the extension to select a query language, read document and graph results, or inspect document collection metadata.

Supported data models and languages

Model Language identifier Query results
Relational sql RelationalResult for row frames, ScalarResult for scalar responses.
Document mongo DocumentResult for document frames, ScalarResult for scalar responses. Enable the corresponding query language plugin on the server. The server determines the result shape.
Graph cypher GraphResult for graph frames, RelationalResult for projections with scalar columns, and ScalarResult for scalar responses.

An MQL write can return a document containing an update count. Inspect the result type before choosing how to read it. This matters especially when you execute dynamic queries.

Unwrapping for multi-model support

Open a regular JDBC connection and call connection.unwrap(PolyConnection.class). On that connection, use createPolyStatement(). Pass the namespace, language identifier, and query to execute. JDBC and multimodel statements share the connection’s session and autocommit setting.

Use Result.getResultType() or a Java type check to identify the response. Result.unwrap(Class<T>) gives you the corresponding typed result. Read it before executing again on the same PolyStatement.

For complete examples, see SQL and transactions, document queries with MongoQL, and graph queries with Cypher.

Cypher results

Use a driver and server with Prism 2.3 support. RETURN n produces an iterable GraphResult, while RETURN n AS person, n.name AS name yields rows with a typed node and a scalar column. Read Cypher results

Document collection metadata

Use PrismInterfaceClient.searchEntities to discover collections and, when the server supports it, their inferred fields, sample documents, and indexes. This uses the same open connection. Query results and collection metadata use separate APIs.

© Polypheny GmbH. All Rights Reserved.