java.sql.Connection represents one Polypheny session over Prism. JDBC schemas correspond to Polypheny namespaces. See the driver reference for URL configuration and PolyConnection for the multimodel extension.
Statements
| Method | Behavior |
|---|---|
createStatement() |
Creates an SQL Statement with the default result set settings. |
createStatement(type, concurrency) and createStatement(type, concurrency, holdability) |
Select cursor type, concurrency and optional holdability. |
prepareStatement(sql) and its cursor configuration overloads |
Prepares parameterized SQL to execute in a PreparedStatement. |
prepareStatement(sql, autoGeneratedKeys), prepareStatement(sql, columnIndexes), prepareStatement(sql, columnNames) |
Generated-key overloads throw SQLFeatureNotSupportedException for valid options. |
prepareCall(...) |
Callable statements are unsupported in every overload. |
nativeSQL(sql) |
JDBC-to-native SQL translation is unsupported. |
The default result set is TYPE_FORWARD_ONLY. Use TYPE_SCROLL_INSENSITIVE for bidirectional movement. Both types require CONCUR_READ_ONLY and CLOSE_CURSORS_AT_COMMIT. Requests for other combinations raise SQLException.
Transactions and session settings
| Method | Behavior |
|---|---|
setAutoCommit(enabled), getAutoCommit() |
Change or read the auto-commit mode. It starts enabled unless the connection options override it. |
commit(), rollback() |
Commit or roll back the current transaction in manual commit mode. With strict=true, calling either while auto-commit is enabled raises SQLException. |
setSavepoint(), setSavepoint(name), releaseSavepoint(savepoint), rollback(savepoint) |
Savepoints are unsupported. |
setTransactionIsolation(level), getTransactionIsolation() |
Set or read the isolation level. Only TRANSACTION_READ_COMMITTED is accepted. |
setHoldability(holdability), getHoldability() |
Set or read cursor holdability. Only CLOSE_CURSORS_AT_COMMIT is accepted. |
setSchema(namespace), getSchema() |
Set the default namespace for subsequent statements or read the configured namespace. getSchema() can be null when the server’s default namespace is in effect and the client did not set one. |
setCatalog(catalog), getCatalog() |
Store and read a client-side catalog name. This does not switch databases on the server. |
setReadOnly(readOnly), isReadOnly() |
Set and read a client-side flag. The server does not enforce that flag. |
setNetworkTimeout(executor, milliseconds), getNetworkTimeout() |
Set or read a non-negative timeout for synchronous Prism requests. 0 waits indefinitely. The driver ignores the executor argument. |
setClientInfo(name, value) and setClientInfo(properties) |
Submit connection properties to the server. Server failures are reported as SQLClientInfoException. |
getClientInfo() and getClientInfo(name) |
Read all client information or a named property. The named form returns null when the property is absent. |
Example transaction
First create and seed public.jdbc_docs_tasks using the Statement setup example. The following example rolls back a change to a task title.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class RollBackTask {
public static void main(String[] args) throws Exception {
String url = args.length == 0 ? "jdbc:polypheny://localhost:20590" : args[0];
try (Connection connection = DriverManager.getConnection(url, "pa", "")) {
connection.setAutoCommit(false);
try (PreparedStatement update = connection.prepareStatement(
"UPDATE public.jdbc_docs_tasks SET title = ? WHERE id = ?")) {
update.setString(1, "Temporary title");
update.setInt(2, 1);
System.out.println(update.executeUpdate());
} finally {
connection.rollback();
}
}
}
}
Replace rollback() with commit() to keep a successful change. If your code commits, retain an explicit rollback path for errors before closing.
Connection and value helpers
| Method | Behavior |
|---|---|
close(), isClosed() |
Close statements tracked by the connection and disconnect from Prism. isClosed() reports local state. |
isValid(timeout) |
Checks an open connection by sending a Prism request. The timeout is in seconds and 0 means no timeout. |
abort(executor) |
Unsupported. |
getWarnings(), clearWarnings() |
getWarnings() returns null. The connection does not track SQL warnings. |
getMetaData() |
Returns JDBC DatabaseMetaData. |
createArrayOf(typeName, elements) |
Creates an in-memory SQL Array from Java values and the Polypheny element type name, such as INTEGER. |
createBlob(), createClob(), createNClob() |
Create in-memory large objects which can be populated and bound as supported parameter types. |
createStruct(typeName, attributes) |
Creates an in-memory Struct. Binding this object to a prepared statement is unsupported. |
createSQLXML() |
Unsupported. |
getTypeMap(), setTypeMap(map) |
Read or replace a local type map. These methods do not add support for server-side user-defined types. |
isWrapperFor(type), unwrap(type) |
Check or obtain the driver implementation. An incompatible unwrap raises SQLException. |
© Polypheny GmbH. All Rights Reserved.