public Connection connect()

in asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverBase.java [139:184]


    public Connection connect(String url, Properties info) throws SQLException {
        if (!acceptsURL(url)) {
            return null;
        }
        URI subUri;
        try {
            subUri = new URI(url.substring(JDBC_SCHEME.length()));
        } catch (URISyntaxException e) {
            throw errorReporter.errorParameterValueNotSupported("URL");
        }
        String host = subUri.getHost();
        if (host == null) {
            throw errorReporter.errorParameterValueNotSupported("URL");
        }
        int port = subUri.getPort();
        if (port <= 0) {
            port = defaultApiPort;
        }

        Map<ADBDriverProperty, Object> properties = new HashMap<>();
        Map<String, ADBDriverProperty> supportedProperties = getOrCreateSupportedPropertiesIndex();
        SQLWarning warning = new SQLWarning();
        parseConnectionProperties(getURIParameters(subUri), properties, supportedProperties, warning);
        parseConnectionProperties(info, properties, supportedProperties, warning);
        warning = warning.getNextWarning() != null ? warning.getNextWarning() : null;

        checkDriverVersion(properties);

        String dataverseCanonicalName = getDataverseCanonicalNameFromURI(subUri);

        ADBDriverContext driverContext = getOrCreateDriverContext();
        ADBProtocolBase protocol = createProtocol(host, port, properties, driverContext);
        try {
            String serverVersion = protocol.connect();
            ADBProductVersion databaseVersion = protocol.parseDatabaseVersion(serverVersion);
            checkDatabaseVersion(properties, databaseVersion);
            return createConnection(protocol, url, databaseVersion, dataverseCanonicalName, properties, warning);
        } catch (SQLException e) {
            try {
                protocol.close();
            } catch (SQLException e2) {
                e.addSuppressed(e2);
            }
            throw e;
        }
    }