Additional top-level class in compilation unit: DriverInfo.
Note
The javax. interface, provides
another way to connect to a data source.
The use of a DataSource object is the preferred means of
connecting to a data source.
As part of its initialization, the DriverManager class will
attempt to load available JDBC drivers by using:
jdbc.drivers system property which contains a
colon separated list of fully qualified class names of JDBC drivers. Each
driver is loaded using the system class loader:
jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver
java.sql.Driver class, that are loaded
via the service-provider loading mechanism.
Implementation Note
DriverManager initialization is done lazily and looks up service
providers using the thread context class loader. The drivers loaded and
available to an application will depend on the thread context class loader of
the thread that triggers driver initialization by DriverManager.
When the method getConnection is called,
the DriverManager will attempt to
locate a suitable driver from amongst those loaded at
initialization and those loaded explicitly using the same class loader
as the current application.
Driver, Connection
| Modifier and Type | Field and Description |
|---|---|
| private static volatile boolean | |
| private static final String | |
| private static final Object | |
| private static volatile int | |
| private static volatile PrintStream | |
| private static final Object | |
| private static volatile PrintWriter | |
| private static final CopyOnWriteArrayList |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static void | deregisterDriver(Driver
the JDBC Driver to remove driver)Removes the specified driver from the |
| public static Stream | Returns: the stream of JDBC Drivers loaded by the caller's class loaderRetrieves a Stream with all of the currently loaded JDBC drivers to which the current caller has access. |
| private static void | |
| public static Connection | Returns: a Connection to the URLa database url of the form
url, Properties jdbc:subprotocol:subnamea list of arbitrary string tag/value pairs as
connection arguments; normally at least a "user" and
"password" property should be included info)Attempts to establish a connection to the given database URL. |
| public static Connection | Returns: a connection to the URLa database url of the form
url, String jdbc:subprotocol:subnamethe database user on whose behalf the connection is being
made user, String the user's password password)Attempts to establish a connection to the given database URL. |
| public static Connection | Returns: a connection to the URLa database url of the form
url) jdbc:subprotocol:subnameAttempts to establish a connection to the given database URL. |
| private static Connection | |
| public static Driver | |
| public static Enumeration | Returns: the list of JDBC Drivers loaded by the caller's class loaderRetrieves an Enumeration with all of the currently loaded JDBC drivers to which the current caller has access. |
| private static List | |
| public static int | Returns: the driver login time limit in secondsGets the maximum time in seconds that a driver can wait when attempting to log in to a database. |
| public static PrintStream | Returns: the logging/tracing PrintStream; if disabled, isnull
Deprecated
since 1.2. Use
getLogWriter
Retrieves the logging/tracing PrintStream that is used by the |
| public static PrintWriter | |
| private static boolean | |
| private static boolean | |
| public static void | |
| public static void | registerDriver(Driver
the new JDBC Driver that is to be registered with the
driver)DriverManagerRegisters the given driver with the |
| public static void | registerDriver(Driver
the new JDBC Driver that is to be registered with the
driver, DriverAction DriverManagerthe da)DriverAction implementation to be used when
DriverManager#deregisterDriver is calledRegisters the given driver with the |
| public static void | setLoginTimeout(int
the login time limit in seconds; zero means there is no limit seconds)Sets the maximum time in seconds that a driver will wait while attempting to connect to a database once the driver has been identified. |
| public static void | setLogStream(PrintStream
the new logging/tracing PrintStream; to disable, set to out)null
Deprecated
since 1.2. Use
setLogWriter
Sets the logging/tracing PrintStream that is used
by the |
| public static void | setLogWriter(PrintWriter
the new logging/tracing out)PrintStream object;
null to disable logging and tracingSets the logging/tracing |
| driversInitialized | back to summary |
|---|---|
| private static volatile boolean driversInitialized | |
| JDBC_DRIVERS_PROPERTY | back to summary |
|---|---|
| private static final String JDBC_DRIVERS_PROPERTY | |
| lockForInitDrivers | back to summary |
|---|---|
| private static final Object lockForInitDrivers | |
| loginTimeout | back to summary |
|---|---|
| private static volatile int loginTimeout | |
| logStream | back to summary |
|---|---|
| private static volatile PrintStream logStream | |
| logSync | back to summary |
|---|---|
| private static final Object logSync | |
| logWriter | back to summary |
|---|---|
| private static volatile PrintWriter logWriter | |
| registeredDrivers | back to summary |
|---|---|
| private static final CopyOnWriteArrayList<DriverInfo> registeredDrivers | |
| DriverManager | back to summary |
|---|---|
| private DriverManager() | |
| deregisterDriver | back to summary |
|---|---|
| public static void deregisterDriver(Driver driver) throws SQLException Removes the specified driver from the
If a If the specified driver is not found in the list of registered drivers, then no action is taken. If the driver was found, it will be removed from the list of registered drivers.
If a
| |
| drivers | back to summary |
|---|---|
| public static Stream Retrieves a Stream with all of the currently loaded JDBC drivers to which the current caller has access. | |
| ensureDriversInitialized | back to summary |
|---|---|
| private static void ensureDriversInitialized() | |
| getConnection | back to summary |
|---|---|
| public static Connection getConnection(String url, Properties info) throws SQLException Attempts to establish a connection to the given database URL.
The Note If a property is specified as part of the
| |
| getConnection | back to summary |
|---|---|
| public static Connection getConnection(String url, String user, String password) throws SQLException Attempts to establish a connection to the given database URL.
The Note If the
| |
| getConnection | back to summary |
|---|---|
| public static Connection getConnection(String url) throws SQLException Attempts to establish a connection to the given database URL.
The
| |
| getConnection | back to summary |
|---|---|
private static Connection getConnection(String url, Properties info, Class<?> caller) throws SQLException
| |
| getDriver | back to summary |
|---|---|
| public static Driver getDriver(String url) throws SQLException Attempts to locate a driver that understands the given URL.
The
| |
| getDrivers | back to summary |
|---|---|
| public static Enumeration Retrieves an Enumeration with all of the currently loaded JDBC drivers to which the current caller has access. Note The classname of a driver can be found using
| |
| getDrivers | back to summary |
|---|---|
| private static List | |
| getLoginTimeout | back to summary |
|---|---|
| public static int getLoginTimeout() Gets the maximum time in seconds that a driver can wait when attempting to log in to a database.
| |
| getLogStream | back to summary |
|---|---|
| public static PrintStream getLogStream()
Deprecated since 1.2. Use Retrieves the logging/tracing PrintStream that is used by the
| |
| getLogWriter | back to summary |
|---|---|
| public static PrintWriter getLogWriter() Retrieves the log writer.
The
| |
| isDriverAllowed | back to summary |
|---|---|
| private static boolean isDriverAllowed(Driver driver, Class<?> caller) | |
| isDriverAllowed | back to summary |
|---|---|
| private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) | |
| println | back to summary |
|---|---|
| public static void println(String message) Prints a message to the current JDBC log stream.
| |
| registerDriver | back to summary |
|---|---|
| public static void registerDriver(Driver driver) throws SQLException Registers the given driver with the
| |
| registerDriver | back to summary |
|---|---|
| public static void registerDriver(Driver driver, DriverAction da) throws SQLException Registers the given driver with the
| |
| setLoginTimeout | back to summary |
|---|---|
| public static void setLoginTimeout(int seconds) Sets the maximum time in seconds that a driver will wait while attempting to connect to a database once the driver has been identified.
| |
| setLogStream | back to summary |
|---|---|
| public static void setLogStream(PrintStream out)
Deprecated since 1.2. Use Sets the logging/tracing PrintStream that is used
by the
| |
| setLogWriter | back to summary |
|---|---|
| public static void setLogWriter(PrintWriter out) Sets the logging/tracing
| |