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 TypeMethodDescriptionboolean
acceptsURL
(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.int
Gets the major version.int
Gets the minor version.Gets the parent logger.getPropertyInfo
(String url, Properties info) Gets the property info.static Driver
getRealDriver
(String jdbcURL) Gets the real driver.static String
getRealDriverName
(String jdbcURL) Gets the real driver name of the underlying driver.static String
getRealURL
(String jdbcURL) Gets the real JDBC URL of the underlying driver.boolean
Jdbc compliant.static void
register()
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
DriverManager
finds 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 firstSQLException
it 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:
acceptsURL
in 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:
connect
in 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:
getMajorVersion
in interfaceDriver
- Returns:
- major version
-
getMinorVersion
public int getMinorVersion()Gets the minor version.- Specified by:
getMinorVersion
in interfaceDriver
- Returns:
- the minor version
-
getPropertyInfo
Gets the property info.- Specified by:
getPropertyInfo
in interfaceDriver
- Parameters:
url
- the urlinfo
- the info- Returns:
- the property info
- Throws:
SQLException
- the SQL exception
-
jdbcCompliant
public boolean jdbcCompliant()Jdbc compliant.- Specified by:
jdbcCompliant
in interfaceDriver
- Returns:
- true, if successful
-
getParentLogger
Gets the parent logger. This method is needed for the support of Java 5.- Specified by:
getParentLogger
in interfaceDriver
- Returns:
- the parent logger
- Throws:
SQLFeatureNotSupportedException
- the SQL feature not supported exception
-
toString
-