patterntesting.runtime.monitor.db
Class ProxyDriver

Package class diagram package ProxyDriver
java.lang.Object
  extended by patterntesting.runtime.monitor.db.ProxyDriver
All Implemented Interfaces:
Driver
Direct Known Subclasses:
ProxyDriver

public class ProxyDriver
extends Object
implements Driver

This JDBC driver acts like a proxy between PatternTesting and the real JDBC driver to be able to monitor JDBC access. It was inspired by the JAMonDriver of the JAMon framework.

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:
1.4.1 (27.03.2014)
Version:
$Revision: 1.1 $
Author:
oliver

Constructor Summary
ProxyDriver()
           
 
Method Summary
 boolean acceptsURL(String url)
          Retrieves whether the driver thinks that it can open a connection to the given URL.
 Connection connect(String url, Properties info)
          Attempts to make a database connection to the given URL.
 int getMajorVersion()
          Gets the major version
 int getMinorVersion()
          Gets the minor version.
 Logger getParentLogger()
          Gets the parent logger.
 DriverPropertyInfo[] 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 jdbcCompliant()
          Jdbc compliant.
static void register()
          Registers the driver as JDBC driver.
 String toString()
          Better toString implementation which supports logging and debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProxyDriver

public ProxyDriver()
Method Detail

register

public static void register()
Registers the driver as JDBC driver.


getRealURL

public static String getRealURL(String jdbcURL)
Gets the real JDBC URL of the underlying driver.

Parameters:
jdbcURL - the jdbc url, e.g. "jdbc:proxy:hsqldb:mem:testdb"
Returns:
the real driver name

getRealDriverName

public static String getRealDriverName(String jdbcURL)
Gets the real driver name of the underlying driver.

Parameters:
jdbcURL - the jdbc url, e.g. "jdbc:proxy:hsqldb:mem:testdb"
Returns:
the real driver name

getRealDriver

public static Driver getRealDriver(String jdbcURL)
Gets the real driver.

Parameters:
jdbcURL - the jdbc url, e.g. "jdbc:proxy:hsqldb:mem:testdb"
Returns:
the real driver

acceptsURL

public boolean acceptsURL(String url)
Retrieves whether the driver thinks that it can open a connection to the given URL. Accepted URLs are URLs beginning with:

Specified by:
acceptsURL in interface Driver
Parameters:
url - the JDBC URL
Returns:
true, if successful
See Also:
Driver.acceptsURL(String)

connect

public Connection connect(String url,
                          Properties info)
                   throws SQLException
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 interface Driver
Parameters:
url - the url
info - the info (e.g. user/password)
Returns:
the connection
Throws:
SQLException - the sQL exception
See Also:
Driver.connect(String, Properties)

getMajorVersion

public int getMajorVersion()
Gets the major version

Specified by:
getMajorVersion in interface Driver
Returns:
major version

getMinorVersion

public int getMinorVersion()
Gets the minor version.

Specified by:
getMinorVersion in interface Driver
Returns:
the minor version

getPropertyInfo

public DriverPropertyInfo[] getPropertyInfo(String url,
                                            Properties info)
                                     throws SQLException
Gets the property info.

Specified by:
getPropertyInfo in interface Driver
Parameters:
url - the url
info - the info
Returns:
the property info
Throws:
SQLException - the SQL exception

jdbcCompliant

public boolean jdbcCompliant()
Jdbc compliant.

Specified by:
jdbcCompliant in interface Driver
Returns:
true, if successful

getParentLogger

public Logger getParentLogger()
                       throws SQLFeatureNotSupportedException
Gets the parent logger. This method is needed for the support of Java 5.

Returns:
the parent logger
Throws:
SQLFeatureNotSupportedException - the SQL feature not supported exception

toString

public String toString()
Better toString implementation which supports logging and debugging.

Overrides:
toString in class Object
Returns:
the string
See Also:
Object.toString()


Copyright © 2002–2014 PatternTesting Team. All rights reserved.