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.DriverImplementation 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()andgetConnectStringPrefix(), and may overridecreateFactory().The provider must implement:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classUnregisteredDriver.JdbcVersionJDBC version.
-
Field Summary
Fields Modifier and Type Field Description protected AvaticaFactoryfactoryHandlerhandler(package private) DriverVersionversion
-
Constructor Summary
Constructors Modifier Constructor Description protectedUnregisteredDriver()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanacceptsURL(java.lang.String url)java.sql.Connectionconnect(java.lang.String url, java.util.Properties info)protected abstract DriverVersioncreateDriverVersion()Creates an object describing the name and version of this driver.protected AvaticaFactorycreateFactory()Creates a factory for JDBC objects (connection, statement).protected HandlercreateHandler()Creates a Handler.abstract MetacreateMeta(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.StringgetConnectStringPrefix()Returns the prefix of the connect string that this driver will recognize as its own.DriverVersiongetDriverVersion()Returns the driver version object.protected java.lang.StringgetFactoryClassName(UnregisteredDriver.JdbcVersion jdbcVersion)Returns the name of a class to be factory for JDBC objects (connection, statement) appropriate for the current JDBC version.intgetMajorVersion()intgetMinorVersion()java.util.logging.LoggergetParentLogger()java.sql.DriverPropertyInfo[]getPropertyInfo(java.lang.String url, java.util.Properties info)private static java.lang.RuntimeExceptionhandle(java.lang.String msg, java.lang.Throwable e)protected static AvaticaFactoryinstantiateFactory(java.lang.String factoryClassName)Helper method for creating factories.booleanjdbcCompliant()protected voidregister()Registers this driver with the driver manager.
-
-
-
Field Detail
-
version
final DriverVersion version
-
factory
protected final AvaticaFactory factory
-
handler
public final Handler handler
-
-
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(), thengetFactoryClassName(org.apache.calcite.avatica.UnregisteredDriver.JdbcVersion)with that version, then passes that class name toinstantiateFactory(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:
connectin interfacejava.sql.Driver- Throws:
java.sql.SQLException
-
acceptsURL
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException- Specified by:
acceptsURLin interfacejava.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:
getPropertyInfoin interfacejava.sql.Driver- Throws:
java.sql.SQLException
-
getParentLogger
public java.util.logging.Logger getParentLogger()
- Specified by:
getParentLoggerin interfacejava.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:
getMajorVersionin interfacejava.sql.Driver
-
getMinorVersion
public final int getMinorVersion()
- Specified by:
getMinorVersionin interfacejava.sql.Driver
-
jdbcCompliant
public boolean jdbcCompliant()
- Specified by:
jdbcCompliantin interfacejava.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.
-
-