JDBC Driver - DatabaseMetaData - Basic

On this page

Connection.getMetaData() returns java.sql.DatabaseMetaData. Use these methods to identify the server and driver, catalog methods to inspect entities, and capability flags to see the values reported by the driver.

Method Driver 3.1 behavior
getConnection() Returns the connection from which the metadata was obtained.
getURL() Returns the host and port URL, with no credentials, namespace path or other options.
getUserName() Returns the username supplied in the connection settings, if present.
getDatabaseProductName(), getDatabaseProductVersion() Return the product name and version string from the server.
getDatabaseMajorVersion(), getDatabaseMinorVersion() In 3.1 both accessors return the server’s minor version. Use getDatabaseProductVersion() for the actual version.
getDriverName(), getDriverVersion() Return the driver name and version string.
getDriverMajorVersion(), getDriverMinorVersion() Return the driver version components.
getJDBCMajorVersion(), getJDBCMinorVersion() The 3.1 implementation returns the driver version components here too. These fields do not report the JDBC API level.
getSQLKeywords() Comma-separated nonstandard SQL keywords advertised by Polypheny.
getNumericFunctions(), getStringFunctions(), getSystemFunctions(), getTimeDateFunctions() Comma-separated SQL function names advertised by Polypheny for each category.
supportsResultSetType(type), supportsResultSetConcurrency(type, concurrency) Check the cursor settings accepted by the driver.
supportsResultSetHoldability(holdability), getResultSetHoldability() The supported and default holdability is CLOSE_CURSORS_AT_COMMIT.
isWrapperFor(type), unwrap(type) Check or obtain the compatible metadata implementation.

Example: print server and driver versions

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;

public class ReportVersions {
    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", "")) {
            DatabaseMetaData meta = connection.getMetaData();
            System.out.println(meta.getDatabaseProductName() + " " + meta.getDatabaseProductVersion());
            System.out.println(meta.getDriverName() + " " + meta.getDriverVersion());
        }
    }
}
© Polypheny GmbH. All Rights Reserved.