Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.sql

Class DriverManager

java.lang.Object
|
+--java.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.

Author:

Method Summary

static voidderegisterDriver(java.sql.Driver driver)

This method de-registers a driver from the manager.
static java.sql.ConnectiongetConnection(java.lang.String url, java.util.Properties properties)

This method attempts to return a connection to the specified JDBC URL string using the specified connection properties.
static java.sql.ConnectiongetConnection(java.lang.String url, java.lang.String user, java.lang.String password)

This method attempts to return a connection to the specified JDBC URL string using the specified username and password.
static java.sql.ConnectiongetConnection(java.lang.String url)

This method attempts to return a connection to the specified JDBC URL string.
static java.sql.DrivergetDriver(java.lang.String url)

This method returns a driver that can connect to the specified JDBC URL string.
static java.util.EnumerationgetDrivers()

This method returns a list of all the currently registered JDBC drivers that were loaded by the current ClassLoader.
static java.io.PrintStreamgetLogStream()

This method returns the log stream in use by JDBC.
static java.io.PrintWritergetLogWriter()

This method returns the log writer being used by all JDBC drivers.
static intgetLoginTimeout()

This method returns the login timeout in use by JDBC drivers systemwide.
static voidprintln(java.lang.String message)

This method prints the specified line to the log stream.
static voidregisterDriver(java.sql.Driver driver)

This method registers a new driver with the manager.
static voidsetLogStream(java.io.PrintStream out)

This method sets the log stream in use by JDBC.
static voidsetLogWriter(java.io.PrintWriter out)

This method sets the log writer being used by JDBC drivers.
static voidsetLoginTimeout(int seconds)

This method set the login timeout used by JDBC drivers.

Method Details

deregisterDriver

public static void deregisterDriver(java.sql.Driver driver)

This method de-registers a driver from the manager.

Parameters:

Throws:


getConnection

public static Connection getConnection(java.lang.String url)

This method attempts to return a connection to the specified JDBC URL string.

Parameters:

Returns:

Throws:


getConnection

public static Connection getConnection(java.lang.String url, java.lang.String user, java.lang.String password)

This method attempts to return a connection to the specified JDBC URL string using the specified username and password.

Parameters:

Returns:

Throws:


getConnection

public static Connection getConnection(java.lang.String url, java.util.Properties properties)

This method attempts to return a connection to the specified JDBC URL string using the specified connection properties.

Parameters:

Returns:

Throws:


getDriver

public static Driver getDriver(java.lang.String url)

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:

Returns:

Throws:


getDrivers

public static Enumeration getDrivers()

This method returns a list of all the currently registered JDBC drivers that were loaded by the current ClassLoader.

Returns:


getLogStream

public static PrintStream getLogStream()

This method returns the log stream in use by JDBC.

Returns:


getLogWriter

public static PrintWriter getLogWriter()

This method returns the log writer being used by all JDBC drivers. This method should be used in place of the deprecated getLogStream method.

Returns:


getLoginTimeout

public static int getLoginTimeout()

This method returns the login timeout in use by JDBC drivers systemwide.

Returns:


println

public static void println(java.lang.String message)

This method prints the specified line to the log stream.

Parameters:


registerDriver

public static void registerDriver(java.sql.Driver driver)

This method registers a new driver with the manager. This is normally called by the driver itself in a static initializer.

Parameters:

Throws:


setLogStream

public static void setLogStream(java.io.PrintStream out)

This method sets the log stream in use by JDBC.

Parameters:


setLogWriter

public static void setLogWriter(java.io.PrintWriter out)

This method sets the log writer being used by JDBC drivers. This is a system-wide parameter that affects all drivers. Note that since there is no way to retrieve a PrintStream from a PrintWriter, this method cannot set the log stream in use by JDBC. Thus any older drivers may not see this setting.

Parameters:


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: