Package org.apache.calcite.avatica

# Class UnregisteredDriver

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

All Implemented Interfaces:
  `Driver`

Direct Known Subclasses:
  `Driver`

public abstract class UnregisteredDriver extends Object implements 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
Modifier and Type
Class
Description
`protected static enum`
`UnregisteredDriver.JdbcVersion`
JDBC version.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final AvaticaFactory`
`factory`
`final Handler`
`handler`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`UnregisteredDriver()`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`acceptsURL(String url)`
`Connection`
`connect(String url, 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 Collection<ConnectionProperty>`
`getConnectionProperties()`
Returns the connection properties supported by this driver.
`protected abstract 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 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.
`final int`
`getMajorVersion()`
`final int`
`getMinorVersion()`
`Logger`
`getParentLogger()`
`DriverPropertyInfo[]`
`getPropertyInfo(String url, Properties info)`
`protected static AvaticaFactory`
`instantiateFactory(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 Details

### factory

protected final AvaticaFactory factory

### handler

public final Handler handler

## Constructor Details

### UnregisteredDriver

protected UnregisteredDriver()

## Method Details

### 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 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 Collection<ConnectionProperty> getConnectionProperties()
Returns the connection properties supported by this driver.

### instantiateFactory

protected static AvaticaFactory instantiateFactory(String factoryClassName)
Helper method for creating factories.

### connect

public Connection connect(String url, Properties info) throws SQLException

Specified by:
  `connect` in interface `Driver`
Throws:
  `SQLException`

### acceptsURL

public boolean acceptsURL(String url) throws SQLException

Specified by:
  `acceptsURL` in interface `Driver`
Throws:
  `SQLException`

### getConnectStringPrefix

protected abstract String getConnectStringPrefix()
Returns the prefix of the connect string that this driver will recognize as its own. For example, "jdbc:calcite:".

### getPropertyInfo

public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException

Specified by:
  `getPropertyInfo` in interface `Driver`
Throws:
  `SQLException`

### getParentLogger

public Logger getParentLogger()

Specified by:
  `getParentLogger` in interface `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 `Driver`

### getMinorVersion

public final int getMinorVersion()

Specified by:
  `getMinorVersion` in interface `Driver`

### jdbcCompliant

public boolean jdbcCompliant()

Specified by:
  `jdbcCompliant` in interface `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.