public class JDBCDriverShim extends Object implements Driver
Class.forName() to find and load the JDBC Driver class is that it
presumes that your driver is in the classpath. This means either packaging the driver in your jar, or having to
stick the driver somewhere (probably unpacking it too), or modifying your classpath.
But why not use something like URLClassLoader and the overload of Class.forName() that lets you specify the
ClassLoader?" Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.
The workaround for this is to create a shim class that implements java.sql.Driver.
This shim class will do nothing but call the methods of an instance of a JDBC driver that we loaded dynamically.DataDrivenETLDBInputFormat,
ETLDBOutputFormat| Constructor and Description |
|---|
JDBCDriverShim(Driver delegate) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsURL(String url) |
Connection |
connect(String url,
Properties info) |
int |
getMajorVersion() |
int |
getMinorVersion() |
Logger |
getParentLogger() |
DriverPropertyInfo[] |
getPropertyInfo(String url,
Properties info) |
boolean |
jdbcCompliant() |
public JDBCDriverShim(Driver delegate)
public boolean acceptsURL(String url) throws SQLException
acceptsURL in interface DriverSQLExceptionpublic Connection connect(String url, Properties info) throws SQLException
connect in interface DriverSQLExceptionpublic int getMajorVersion()
getMajorVersion in interface Driverpublic int getMinorVersion()
getMinorVersion in interface Driverpublic DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
getPropertyInfo in interface DriverSQLExceptionpublic boolean jdbcCompliant()
jdbcCompliant in interface Driverpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface DriverSQLFeatureNotSupportedExceptionCopyright © 2017 Cask Data, Inc. Licensed under the Apache License, Version 2.0.