com.cometway.jdbc
Class JDBCConnectionDriver

java.lang.Object
  extended by com.cometway.jdbc.JDBCConnectionDriver
All Implemented Interfaces:
java.sql.Driver

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

The JDBCConnectionDriver class provides access to pooled JDBCConnections. Connections will be reaped after they are stale for a while, but it's still important to call JDBCConnection.close() or the available connections will get used up.


Field Summary
protected  ReporterInterface reporter
           
 java.lang.String URL_PREFIX
           
 
Constructor Summary
JDBCConnectionDriver(java.lang.String jdbcDriver, java.lang.String jdbcURL, java.lang.String jdbcUsername, java.lang.String jdbcPassword, ReporterInterface reporter)
           
 
Method Summary
 boolean acceptsURL(java.lang.String jdbcURL)
          This method is needed to implement the driver interface.
 JDBCConnection connect()
          Returns a connection from the JDBC Connection Pool.
 java.sql.Connection connect(java.lang.String jdbcURL, java.util.Properties props)
          Called by the JDBCConnection threads to get a real connection to the Database via the JDBC Driver.
 void debug(java.lang.String message)
          Prints a debug message tagged with this JDBCConnectionDriver's identity to the output stream.
 void error(java.lang.String message)
          Prints an error message tagged with this JDBCConnectionDriver's identity to the error stream.
 void error(java.lang.String message, java.lang.Exception e)
          Prints an error message tagged with this JDBCConnectionDriver's identity followed by a stack trace of the passed Exception to the error stream.
protected  java.sql.Connection getConnection(java.lang.String jdbcURL, java.lang.String jdbcUsername, java.lang.String jdbcPassword)
          Called by the JDBCConnection threads to get a real connection to the Database via the JDBC Driver.
 int getMajorVersion()
          Retrieves the driver's major version number.
 int getMinorVersion()
          Gets the driver's minor version number.
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String str, java.util.Properties props)
          Gets information about the possible properties for this driver.
 boolean jdbcCompliant()
          This driver is not JDBC Compliant.
 void println(java.lang.String message)
          Prints a message tagged with this connection's identity to the output stream.
 void setReporter(ReporterInterface reporter)
          Sets the reporter for this Connection.
 void warning(java.lang.String message)
          Prints a warning message tagged with this JDBCConnectionDriver's identity to the error stream.
 void warning(java.lang.String message, java.lang.Exception e)
          Prints an warning message tagged with this JDBCConnectionDriver's identity followed by a stack trace of the passed Exception to error stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_PREFIX

public java.lang.String URL_PREFIX

reporter

protected ReporterInterface reporter
Constructor Detail

JDBCConnectionDriver

public JDBCConnectionDriver(java.lang.String jdbcDriver,
                            java.lang.String jdbcURL,
                            java.lang.String jdbcUsername,
                            java.lang.String jdbcPassword,
                            ReporterInterface reporter)
                     throws java.lang.ClassNotFoundException,
                            java.lang.InstantiationException,
                            java.lang.IllegalAccessException,
                            java.sql.SQLException
Parameters:
jdbcDriver - The classname of the JDBCDriver to load, for instance com.ms.jdbc.odbc.JdbcOdbcDriver
jdbcURL - The JDBC URL to use when connecting to the DB, for instance JDBC:ODBC:viaDB
jdbcUsername - The username to use when connecting to the DB.
jdbcPassword - The password to use when connecting to the DB.
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.sql.SQLException
Method Detail

acceptsURL

public boolean acceptsURL(java.lang.String jdbcURL)
This method is needed to implement the driver interface.

Specified by:
acceptsURL in interface java.sql.Driver
Parameters:
jdbcURL -

connect

public JDBCConnection connect()
                       throws java.sql.SQLException
Returns a connection from the JDBC Connection Pool. These connections should be closed manually.

Returns:
com.cometway.jdbc.JDBCConnection
Throws:
java.sql.SQLException

connect

public java.sql.Connection connect(java.lang.String jdbcURL,
                                   java.util.Properties props)
                            throws java.sql.SQLException
Called by the JDBCConnection threads to get a real connection to the Database via the JDBC Driver.

Specified by:
connect in interface java.sql.Driver
Parameters:
jdbcURL - The JDBC URL to use.
props - The Properties object containing the username and password to use.
Throws:
java.sql.SQLException

getConnection

protected java.sql.Connection getConnection(java.lang.String jdbcURL,
                                            java.lang.String jdbcUsername,
                                            java.lang.String jdbcPassword)
                                     throws java.sql.SQLException
Called by the JDBCConnection threads to get a real connection to the Database via the JDBC Driver.

Parameters:
jdbcURL - The JDBC URL to use
jdbcUsername - The JDBC username
jdbcPassword - The JDBC password
Returns:
com.cometway.jdbc.JDBCConnection
Throws:
java.sql.SQLException - Usually thrown when there is a security problem.

getMajorVersion

public int getMajorVersion()
Retrieves the driver's major version number.

Specified by:
getMajorVersion in interface java.sql.Driver

getMinorVersion

public int getMinorVersion()
Gets the driver's minor version number.

Specified by:
getMinorVersion in interface java.sql.Driver

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String str,
                                                     java.util.Properties props)
Gets information about the possible properties for this driver. There is no information about this driver.

Specified by:
getPropertyInfo in interface java.sql.Driver

jdbcCompliant

public boolean jdbcCompliant()
This driver is not JDBC Compliant.

Specified by:
jdbcCompliant in interface java.sql.Driver

debug

public void debug(java.lang.String message)
Prints a debug message tagged with this JDBCConnectionDriver's identity to the output stream.


warning

public void warning(java.lang.String message)
Prints a warning message tagged with this JDBCConnectionDriver's identity to the error stream. If the Exception is type java.lang.reflect.InvocationTargetException that exception's target exception is also stack traced.


warning

public void warning(java.lang.String message,
                    java.lang.Exception e)
Prints an warning message tagged with this JDBCConnectionDriver's identity followed by a stack trace of the passed Exception to error stream. If the Exception is type java.lang.reflect.InvocationTargetException that exception's target exception is also stack traced.


error

public void error(java.lang.String message)
Prints an error message tagged with this JDBCConnectionDriver's identity to the error stream. If the Exception is type java.lang.reflect.InvocationTargetException that exception's target exception is also stack traced.


error

public void error(java.lang.String message,
                  java.lang.Exception e)
Prints an error message tagged with this JDBCConnectionDriver's identity followed by a stack trace of the passed Exception to the error stream. If the Exception is type java.lang.reflect.InvocationTargetException that exception's target exception is also stack traced.


println

public void println(java.lang.String message)
Prints a message tagged with this connection's identity to the output stream.


setReporter

public void setReporter(ReporterInterface reporter)
Sets the reporter for this Connection.