Class ProxyDriver
- All Implemented Interfaces:
Driver
This driver is registered for JDBC URLs beginning with "jdbc:proxy: ...". This prefix must follow the real driver path. E.g. if you want to use HSQL as database your URL make look like "jdbc:proxy:hsqldb:file:/tmp/oli".
- Since:
- 0.9
- Author:
- oliver
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsURL(String url) Retrieves whether the driver thinks that it can open a connection to the given URL.connect(String url, Properties info) Attempts to make a database connection to the given URL.intGets the major version.intGets the minor version.Gets the parent logger.getPropertyInfo(String url, Properties info) Gets the property info.static DrivergetRealDriver(String jdbcURL) Gets the real driver.static StringgetRealDriverName(String jdbcURL) Gets the real driver name of the underlying driver.static StringgetRealURL(String jdbcURL) Gets the real JDBC URL of the underlying driver.booleanJdbc compliant.static voidregister()Registers the driver as JDBC driver.toString()Better toString implementation which supports logging and debugging.
-
Constructor Details
-
ProxyDriver
public ProxyDriver()
-
-
Method Details
-
register
public static void register()Registers the driver as JDBC driver.Because the implementation how the
DriverManagerfinds the corresponding driver for a given JDBC-URL is a little stupid - it tries out all drivers if it can work with the URL. In case of problems (e.g. if the network is down) it throws the firstSQLExceptionit got and rethrow it - but this may be not the reason for the error message that the protocoll "jdbc:proxy:..." can not be understood.This is the reason why first all registered drivers are first deregistered and the registered again. This guarantees that the ProxyDriver is the first registered driver.
-
getRealURL
-
getRealDriverName
-
getRealDriver
-
acceptsURL
Retrieves whether the driver thinks that it can open a connection to the given URL. Accepted URLs are URLs beginning with:- jdbc:proxy:...
- jdbc:jamon:... (if JAMon is in the classpath)
- Specified by:
acceptsURLin interfaceDriver- Parameters:
url- the JDBC URL- Returns:
- true, if successful
- See Also:
-
connect
Attempts to make a database connection to the given URL. The driver returns "null" if it realizes it is the wrong kind of driver to connect to the given URL. This will be common, as when the JDBC driver manager is asked to connect to a given URL it passes the URL to each loaded driver in turn.- Specified by:
connectin interfaceDriver- Parameters:
url- the urlinfo- the info (e.g. user/password)- Returns:
- the connection
- Throws:
SQLException- the sQL exception- See Also:
-
getMajorVersion
public int getMajorVersion()Gets the major version.- Specified by:
getMajorVersionin interfaceDriver- Returns:
- major version
-
getMinorVersion
public int getMinorVersion()Gets the minor version.- Specified by:
getMinorVersionin interfaceDriver- Returns:
- the minor version
-
getPropertyInfo
Gets the property info.- Specified by:
getPropertyInfoin interfaceDriver- Parameters:
url- the urlinfo- the info- Returns:
- the property info
- Throws:
SQLException- the SQL exception
-
jdbcCompliant
public boolean jdbcCompliant()Jdbc compliant.- Specified by:
jdbcCompliantin interfaceDriver- Returns:
- true, if successful
-
getParentLogger
Gets the parent logger. This method is needed for the support of Java 5.- Specified by:
getParentLoggerin interfaceDriver- Returns:
- the parent logger
- Throws:
SQLFeatureNotSupportedException- the SQL feature not supported exception
-
toString
-