JDBC Driver - Driver

org.polypheny.jdbc.PolyphenyDriver implements java.sql.Driver and registers with DriverManager when the published JAR is on the application classpath. See installation and compatibility.

Creating a Connection

getConnection

Use DriverManager.getConnection(url, user, password) or pass a Properties object when supplying additional options. For a local development instance with its default credentials:

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class OpenConnection {
    public static void main(String[] args) throws Exception {
        String url = args.length == 0 ? "jdbc:polypheny://localhost:20590" : args[0];
        Properties settings = new Properties();
        settings.setProperty("user", "pa");
        settings.setProperty("password", "");
        settings.setProperty("nwtimeout", "5000");

        try (Connection connection = DriverManager.getConnection(url, settings)) {
            System.out.println(connection.isValid(5));
        }
    }
}

URL Structure

The general form is jdbc:polypheny://[user[:password]@]host[:port][/namespace][?key=value&other=value]. The host defaults to localhost and the port defaults to 20590. A namespace in the URL becomes the connection’s initial namespace. Put credentials in the connection arguments or properties so they stay out of connection URLs.

If an option is present in multiple places, URL query parameters override the Properties object. URL user information and the namespace path take precedence over corresponding query parameters. Use the properties overload to pass an empty password or other values that need no URL encoding.

Connection Properties Details

Property Default Behavior
user, password Server defaults Authenticate the connection. The default local account is pa with an empty password.
namespace Server default Starting namespace. Can also be specified in the URL path.
autocommit true Sets whether the server commits each statement automatically.
nwtimeout 0 Network response timeout in milliseconds for synchronous requests. 0 waits without a timeout.
timezone JVM default Java time zone ID for applicable date and time conversions.
readonly false Sets the client-side connection flag. The driver does not send read-only enforcement to the server.
holdability CLOSE Only CLOSE (ResultSet.CLOSE_CURSORS_AT_COMMIT) is accepted.
isolation COMMITTED Only COMMITTED (Connection.TRANSACTION_READ_COMMITTED) is accepted.
strict true false enables legacy behavior for some metadata methods and manual transaction checks. See catalog metadata.
transport plain The only supported transport is plain Prism over TCP.

Closing a Connection

Use try-with-resources or call Connection.close(). Close each statement and result set as soon as it is no longer needed. In manual commit mode, explicitly commit or roll back the transaction before closing the connection.

More methods

java.sql.Driver method Driver 3.1 behavior
connect(url, properties) Opens a session and negotiates Prism compatibility. Returns null for an unrecognized JDBC URL prefix.
acceptsURL(url) Checks the jdbc:polypheny: prefix. An accepted prefix alone does not validate the URL syntax or establish a connection.
getMajorVersion(), getMinorVersion() Return the driver version components (3 and 1).
getPropertyInfo(url, properties) Returns descriptors for user, password, autocommit, readonly, holdability, isolation and nwtimeout. Some listed choices are only recognized syntactically. The table above shows supported values.
getParentLogger() Throws SQLFeatureNotSupportedException.
jdbcCompliant() Returns true. See the other JDBC reference pages for the behavior of individual methods and optional features.
© Polypheny GmbH. All Rights Reserved.