public abstract class UnregisteredDriver extends Object implements Driver
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:
Modifier and Type | Class and Description |
---|---|
protected static class |
UnregisteredDriver.JdbcVersion
JDBC version.
|
Modifier and Type | Field and Description |
---|---|
protected AvaticaFactory |
factory |
Handler |
handler |
Modifier | Constructor and Description |
---|---|
protected |
UnregisteredDriver() |
Modifier and Type | Method and 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.
|
int |
getMajorVersion() |
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.
|
protected final AvaticaFactory factory
public final Handler handler
protected AvaticaFactory createFactory()
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.
protected Handler createHandler()
protected String getFactoryClassName(UnregisteredDriver.JdbcVersion jdbcVersion)
protected abstract DriverVersion createDriverVersion()
protected Collection<ConnectionProperty> getConnectionProperties()
protected static AvaticaFactory instantiateFactory(String factoryClassName)
public Connection connect(String url, Properties info) throws SQLException
connect
in interface Driver
SQLException
public boolean acceptsURL(String url) throws SQLException
acceptsURL
in interface Driver
SQLException
protected abstract String getConnectStringPrefix()
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
getPropertyInfo
in interface Driver
SQLException
public Logger getParentLogger()
getParentLogger
in interface Driver
public DriverVersion getDriverVersion()
public final int getMajorVersion()
getMajorVersion
in interface Driver
public final int getMinorVersion()
getMinorVersion
in interface Driver
public boolean jdbcCompliant()
jdbcCompliant
in interface Driver
protected void register()
public abstract Meta createMeta(AvaticaConnection connection)
Copyright © 2012-2024 Apache Software Foundation. All Rights Reserved.