superwaba.ext.xplat.sql
Class DriverManager

java.lang.Object
  |
  +--superwaba.ext.xplat.sql.DriverManager

public class DriverManager
extends Object

This class manages the JDBC drivers in the system. It maintains a registry of drivers and locates the appropriate driver to handle a JDBC database URL.

On startup, DriverManager loads all the managers specified by the system property jdbc.drivers. The value of this property should be a colon separated list of fully qualified driver class names. Additional drivers can be loaded at any time by simply loading the driver class with class.forName(String). The driver should automatically register itself in a static initializer.

The methods in this class are all static. This class cannot be instantiated.


Method Summary
static void deregisterDriver(Driver driver)
          This method de-registers a driver from the manager.
static Connection getConnection(String url)
          This method attempts to return a connection to the specified JDBC URL string.
static Connection getConnection(String url, Hashtable properties)
          This method attempts to return a connection to the specified JDBC URL string using the specified connection properties.
static Connection getConnection(String url, String user, String password)
          This method attempts to return a connection to the specified JDBC URL string using the specified username and password.
static Driver getDriver(String url)
          This method returns a driver that can connect to the specified JDBC URL string.
static Vector getDrivers()
          This method returns a list of all the currently registered JDBC drivers.
static int getLoginTimeout()
          This method returns the login timeout in use by JDBC drivers systemwide.
static void registerDriver(Driver driver)
          This method registers a new driver with the manager.
static void setLoginTimeout(int seconds)
          This method set the login timeout used by JDBC drivers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Method Detail

getConnection

public static Connection getConnection(String url,
                                       Hashtable properties)
                                throws SQLException
This method attempts to return a connection to the specified JDBC URL string using the specified connection properties.
Parameters:
url - The JDBC URL string to connect to.
properties - The connection properties.
Returns:
A Connection to that URL.
Throws:
SQLException - If an error occurs.

getConnection

public static Connection getConnection(String url,
                                       String user,
                                       String password)
                                throws SQLException
This method attempts to return a connection to the specified JDBC URL string using the specified username and password.
Parameters:
url - The JDBC URL string to connect to.
user - The username to connect with.
password - The password to connect with.
Returns:
A Connection to that URL.
Throws:
SQLException - If an error occurs.

getConnection

public static Connection getConnection(String url)
                                throws SQLException
This method attempts to return a connection to the specified JDBC URL string.
Parameters:
url - The JDBC URL string to connect to.
Returns:
A Connection to that URL.
Throws:
SQLException - If an error occurs.

getDriver

public static Driver getDriver(String url)
                        throws SQLException
This method returns a driver that can connect to the specified JDBC URL string. This will be selected from among drivers loaded at initialization time and those drivers manually loaded by the same class loader as the caller.
Parameters:
url - The JDBC URL string to find a driver for.
Returns:
A Driver that can connect to the specified URL, or null if a suitable driver cannot be found.
Throws:
SQLException - If an error occurs.

registerDriver

public static void registerDriver(Driver driver)
                           throws SQLException
This method registers a new driver with the manager. This is normally called by the driver itself in a static initializer.
Parameters:
driver - The new Driver to add.
Throws:
SQLException - If an error occurs.

deregisterDriver

public static void deregisterDriver(Driver driver)
                             throws SQLException
This method de-registers a driver from the manager.
Parameters:
driver - The Driver to unregister.
Throws:
SQLException - If an error occurs.

getDrivers

public static Vector getDrivers()
This method returns a list of all the currently registered JDBC drivers. WARNING: In SW, the actual Vector containing the drivers is returned. You should not modify the contents of this Vector. It is possible that NULL could be returned if there are no drivers registered.
Returns:
A Vector of all currently loaded JDBC drivers.

setLoginTimeout

public static void setLoginTimeout(int seconds)
This method set the login timeout used by JDBC drivers. This is a system-wide parameter that applies to all drivers.
Parameters:
login_timeout - The new login timeout value.

getLoginTimeout

public static int getLoginTimeout()
This method returns the login timeout in use by JDBC drivers systemwide.
Returns:
The login timeout.