Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.sql.DriverManager
public class DriverManager
extends Object
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 |
|
static Connection |
|
static Connection |
|
static Connection |
|
static Driver | |
static Enumeration |
|
static PrintStream |
|
static PrintWriter |
|
static int |
|
static void | |
static void |
|
static void |
|
static void |
|
static void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static void deregisterDriver(Driver driver) throws SQLException
This method de-registers a driver from the manager.
- Parameters:
driver
- TheDriver
to unregister.
- Throws:
SQLException
- If an error occurs.
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.
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.
public static Connection getConnection(String url, Properties 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.
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.
- Throws:
SQLException
- If an error occurs, or no suitable driver can be found.
public static EnumerationgetDrivers()
This method returns a list of all the currently registered JDBC drivers that were loaded by the currentClassLoader
.
- Returns:
- An
Enumeration
of all currently loaded JDBC drivers.
public static PrintStream getLogStream()
Deprecated. Use
getLogWriter()
instead.This method returns the log stream in use by JDBC.
- Returns:
- The log stream in use by JDBC.
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 deprecatedgetLogStream
method.
- Returns:
- The log writer in use by JDBC drivers.
public static int getLoginTimeout()
This method returns the login timeout in use by JDBC drivers systemwide.
- Returns:
- The login timeout.
public static void println(String message)
This method prints the specified line to the log stream.
- Parameters:
message
- The string to write to the log stream.
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 newDriver
to add.
- Throws:
SQLException
- If an error occurs.
public static void setLogStream(PrintStream stream)
Deprecated. Use
setLogWriter
instead.This method sets the log stream in use by JDBC.
- Parameters:
stream
- The log stream in use by JDBC.
public static void setLogWriter(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 aPrintStream
from aPrintWriter
, this method cannot set the log stream in use by JDBC. Thus any older drivers may not see this setting.
- Parameters:
out
- The new log writer for JDBC.
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:
seconds
- The new login timeout value.