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 when you need a named query language, document results, or document collection metadata.

Supported data models and languages

Model Language identifier Query results in JDBC 3.1
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 Graph frames are unsupported.

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. Both JDBC and multimodel statements use the same session and transaction.

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 and document queries with MQL.

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.