Package org.apache.calcite.avatica

## Class UnregisteredDriver

- java.lang.Object
- - org.apache.calcite.avatica.UnregisteredDriver

All Implemented Interfaces:
  `java.sql.Driver`

Direct Known Subclasses:
  `Driver`

    public abstract class UnregisteredDriver
    extends java.lang.Object
    implements java.sql.Driver

Implementation of JDBC driver that does not register itself.

You can easily create a "vanity driver" that recognizes its own URL prefix as a sub-class of this class. Per the JDBC specification it must register itself when the class is loaded.

Derived classes must implement `createDriverVersion()` and `getConnectStringPrefix()`, and may override `createFactory()`.

The provider must implement:

- `Meta.prepare(Meta.ConnectionHandle, String, long)`
- `Meta.createIterable(org.apache.calcite.avatica.Meta.StatementHandle, org.apache.calcite.avatica.QueryState, org.apache.calcite.avatica.Meta.Signature, java.util.List, Meta.Frame)`

### Nested Class Summary

Nested Classes
`protected static class` `UnregisteredDriver.JdbcVersion` JDBC version.

### Field Summary

Fields
`protected AvaticaFactory` `factory`
`Handler` `handler`
`(package private) DriverVersion` `version`

### Constructor Summary

Constructors
`protected` `UnregisteredDriver()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`boolean` `acceptsURL​(java.lang.String url)`
`java.sql.Connection` `connect​(java.lang.String url, java.util.Properties info)`
`protected abstract DriverVersion` `createDriverVersion()` Creates an object describing the name and version of this driver.
`protected AvaticaFactory` `createFactory()` Creates a factory for JDBC objects (connection, statement).
`protected Handler` `createHandler()` Creates a Handler.
`abstract Meta` `createMeta​(AvaticaConnection connection)` Creates a service handler that will give connections from this Driver their behavior.
`protected java.util.Collection<ConnectionProperty>` `getConnectionProperties()` Returns the connection properties supported by this driver.
`protected abstract java.lang.String` `getConnectStringPrefix()` Returns the prefix of the connect string that this driver will recognize as its own.
`DriverVersion` `getDriverVersion()` Returns the driver version object.
`protected java.lang.String` `getFactoryClassName​(UnregisteredDriver.JdbcVersion jdbcVersion)` Returns the name of a class to be factory for JDBC objects (connection, statement) appropriate for the current JDBC version.
`int` `getMajorVersion()`
`int` `getMinorVersion()`
`java.util.logging.Logger` `getParentLogger()`
`java.sql.DriverPropertyInfo[]` `getPropertyInfo​(java.lang.String url, java.util.Properties info)`
`private static java.lang.RuntimeException` `handle​(java.lang.String msg, java.lang.Throwable e)`
`protected static AvaticaFactory` `instantiateFactory​(java.lang.String factoryClassName)` Helper method for creating factories.
`boolean` `jdbcCompliant()`
`protected void` `register()` Registers this driver with the driver manager.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### version

    final DriverVersion version

#### factory

    protected final AvaticaFactory factory

#### handler

    public final Handler handler

### Constructor Detail

#### UnregisteredDriver

    protected UnregisteredDriver()

### Method Detail

#### createFactory

    protected AvaticaFactory createFactory()

Creates a factory for JDBC objects (connection, statement). Called from the driver constructor.

The default implementation calls `UnregisteredDriver.JdbcVersion.current()`, then `getFactoryClassName(org.apache.calcite.avatica.UnregisteredDriver.JdbcVersion)` with that version, then passes that class name to `instantiateFactory(String)`. This approach is recommended it does not include in the code references to classes that may not be instantiable in all JDK versions. But drivers are free to do it their own way.

Returns:
  JDBC object factory

#### createHandler

    protected Handler createHandler()

Creates a Handler.

#### getFactoryClassName

    protected java.lang.String getFactoryClassName​(UnregisteredDriver.JdbcVersion jdbcVersion)

Returns the name of a class to be factory for JDBC objects (connection, statement) appropriate for the current JDBC version.

#### createDriverVersion

    protected abstract DriverVersion createDriverVersion()

Creates an object describing the name and version of this driver. Called from the driver constructor.

#### getConnectionProperties

    protected java.util.Collection<ConnectionProperty> getConnectionProperties()

Returns the connection properties supported by this driver.

#### instantiateFactory

    protected static AvaticaFactory instantiateFactory​(java.lang.String factoryClassName)

Helper method for creating factories.

#### handle

    private static java.lang.RuntimeException handle​(java.lang.String msg,
                                                     java.lang.Throwable e)

#### connect

    public java.sql.Connection connect​(java.lang.String url,
                                       java.util.Properties info)
                                throws java.sql.SQLException

Specified by:
  `connect` in interface `java.sql.Driver`
Throws:
  `java.sql.SQLException`

#### acceptsURL

    public boolean acceptsURL​(java.lang.String url)
                       throws java.sql.SQLException

Specified by:
  `acceptsURL` in interface `java.sql.Driver`
Throws:
  `java.sql.SQLException`

#### getConnectStringPrefix

    protected abstract java.lang.String getConnectStringPrefix()

Returns the prefix of the connect string that this driver will recognize as its own. For example, "jdbc:calcite:".

#### getPropertyInfo

    public java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url,
                                                         java.util.Properties info)
                                                  throws java.sql.SQLException

Specified by:
  `getPropertyInfo` in interface `java.sql.Driver`
Throws:
  `java.sql.SQLException`

#### getParentLogger

    public java.util.logging.Logger getParentLogger()

Specified by:
  `getParentLogger` in interface `java.sql.Driver`

#### getDriverVersion

    public DriverVersion getDriverVersion()

Returns the driver version object. Not in the JDBC API.

Returns:
  Driver version

#### getMajorVersion

    public final int getMajorVersion()

Specified by:
  `getMajorVersion` in interface `java.sql.Driver`

#### getMinorVersion

    public final int getMinorVersion()

Specified by:
  `getMinorVersion` in interface `java.sql.Driver`

#### jdbcCompliant

    public boolean jdbcCompliant()

Specified by:
  `jdbcCompliant` in interface `java.sql.Driver`

#### register

    protected void register()

Registers this driver with the driver manager.

#### createMeta

    public abstract Meta createMeta​(AvaticaConnection connection)

Creates a service handler that will give connections from this Driver their behavior.