craftsman.spy
Class SpyDriver

java.lang.Object
  extended bycraftsman.spy.SpyDriver
All Implemented Interfaces:
java.sql.Driver

public class SpyDriver
extends java.lang.Object
implements java.sql.Driver

This classe is the implementation of the JDBC driver in order to log any JDBC action. The system property spy.driver MUST contains the real JDBC driver full class name in order to use the Spy driver. Another way is to use a specific JDBC url string like : jdbc:spy:driver_full_class_name:url. The two solutions can be used as the following examples :

 System.setProperty("spy.driver","vendor.database.Driver");// or with the -Dspy.driver=vendor.database.Driver JVM option
 Class.forName("craftsman.spy.SpyDriver");
 Connection c = DriverManager.getConnection("jdbc:database:mydata");
 
 Class.forName("craftsman.spy.SpyDriver");
 Connection c = DriverManager.getConnection("jdbc:spy:vendor.database.Driver:database:mydata");
 

Author:
Sébastien LECACHEUR

Constructor Summary
SpyDriver()
          Constructs a new Spy JDBC driver.
 
Method Summary
 boolean acceptsURL(java.lang.String url)
          Retrieves whether the real driver thinks that it can open a connection to the given URL.
 java.sql.Connection connect(java.lang.String url, java.util.Properties info)
          Attempts to make a database connection to the given URL.
 int getMajorVersion()
          Retrieves the real driver's major version number.
 int getMinorVersion()
          Gets the real driver's minor version number.
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info)
          Gets information about the possible properties for the real driver.
 boolean jdbcCompliant()
          Reports whether thz real driver is a genuine JDBC Compliant driver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpyDriver

public SpyDriver()
          throws java.lang.ClassNotFoundException,
                 java.lang.InstantiationException,
                 java.lang.IllegalAccessException,
                 java.sql.SQLException
Constructs a new Spy JDBC driver.

Throws:
java.lang.ClassNotFoundException - When the real JDBC driver class was not found.
java.lang.InstantiationException - When the real JDBC driver cannot be instancied.
java.lang.IllegalAccessException - When cannot create a new instance of the real JDBC driver.
java.sql.SQLException - When cannot register the Spy JDBC driver or deregistrer the real JDBC driver.
Method Detail

getMajorVersion

public int getMajorVersion()
Retrieves the real driver's major version number. Initially this should be 1.

Specified by:
getMajorVersion in interface java.sql.Driver
Returns:
int This driver's major version number.
See Also:
Driver.getMajorVersion()

getMinorVersion

public int getMinorVersion()
Gets the real driver's minor version number. Initially this should be 0.

Specified by:
getMinorVersion in interface java.sql.Driver
Returns:
int This driver's minor version number.
See Also:
Driver.getMinorVersion()

jdbcCompliant

public boolean jdbcCompliant()
Reports whether thz real driver is a genuine JDBC Compliant driver.

Specified by:
jdbcCompliant in interface java.sql.Driver
Returns:
boolean true if this driver is JDBC Compliant; false otherwise.
See Also:
Driver.jdbcCompliant()

acceptsURL

public boolean acceptsURL(java.lang.String url)
                   throws java.sql.SQLException
Retrieves whether the real driver thinks that it can open a connection to the given URL.

Specified by:
acceptsURL in interface java.sql.Driver
Parameters:
url - String The URL of the database
Returns:
boolean true if this driver understands the given URL; false otherwise.
Throws:
java.sql.SQLException - If a database access error occurs.
See Also:
Driver.acceptsURL(java.lang.String)

connect

public java.sql.Connection connect(java.lang.String url,
                                   java.util.Properties info)
                            throws java.sql.SQLException
Attempts to make a database connection to the given URL.

Specified by:
connect in interface java.sql.Driver
Parameters:
url - String The URL of the database to which to connect.
info - Properties A list of arbitrary string tag/value pairs as connection arguments.
Returns:
Connection A Connection object that represents a connection to the URL.
Throws:
java.sql.SQLException - If a database access error occurs.
See Also:
Driver.connect(java.lang.String, java.util.Properties)

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
                                                     java.util.Properties info)
                                              throws java.sql.SQLException
Gets information about the possible properties for the real driver.

Specified by:
getPropertyInfo in interface java.sql.Driver
Parameters:
url - String The URL of the database to which to connect.
info - Properties A proposed list of tag/value pairs that will be sent on connect open.
Returns:
DriverPropertyInfo[] An array of DriverPropertyInfo objects describing possible properties.
Throws:
java.sql.SQLException - If a database access error occurs.
See Also:
Driver.getPropertyInfo(java.lang.String, java.util.Properties)