public abstract class DriverManager
extends java.lang.Object
java.sql.DriverManager uses a native method to retrieve
the classloader from the calling class which keeps the calling class
(including its classloader) from being garbage collected. Therefore all
accesses to the driver manager have to be encapsulated by a shared class
(this class). Additionally, all JDBC-drivers have to be provided to the
system classloader (and not to the component classloaders).DriverManager| Modifier | Constructor and Description |
|---|---|
protected |
DriverManager()
package protected constructor -> we provide the only implementation
|
| Modifier and Type | Method and Description |
|---|---|
abstract java.sql.Connection |
getConnection(java.lang.String url)
Attempts to establish a connection to the given database URL.
|
abstract java.sql.Connection |
getConnection(java.lang.String url,
java.util.Properties info)
Attempts to establish a connection to the given database URL.
|
abstract java.sql.Connection |
getConnection(java.lang.String url,
java.lang.String user,
java.lang.String password)
Attempts to establish a connection to the given database URL.
|
abstract java.sql.Driver |
getDriver(java.lang.String url)
Attempts to locate a driver that understands the given URL.
|
abstract java.util.Enumeration<java.sql.Driver> |
getDrivers()
Retrieves an Enumeration with all of the currently loaded JDBC drivers
to which the current caller has access.
|
static DriverManager |
getInstance(java.lang.String libDir)
Returns the instance of the JDBC driver manager for the designated directory.
|
abstract int |
getLoginTimeout()
Gets the maximum time in seconds that a driver can wait
when attempting to log in to a database.
|
abstract void |
loadDriver(java.lang.String className)
Gets the class with the designated name.
|
protected DriverManager()
public abstract void loadDriver(java.lang.String className)
throws DriverNotFoundException
Class.forName(className) to enforce the
initialisation of the corresponding driver class.className - The name of the class providing the JDBC-driver which
should be registered.DriverNotFoundException - If the driver could not be loaded. Examine
cause for more information.public abstract java.sql.Connection getConnection(java.lang.String url,
java.util.Properties info)
throws java.sql.SQLException
DriverManager attempts to select an appropriate driver from
the set of registered JDBC drivers.url - a database url of the form
jdbc:subprotocol:subnameinfo - a list of arbitrary string tag/value pairs as connection
arguments; normally at least a "user" and "password" property
should be includedjava.sql.SQLException - if a database access error occurspublic abstract java.sql.Connection getConnection(java.lang.String url,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
DriverManager attempts to select an appropriate driver from
the set of registered JDBC drivers.url - a database url of the form
jdbc:subprotocol:subnameuser - the database user on whose behalf the connection is being madepassword - the user's passwordjava.sql.SQLException - if a database access error occurspublic abstract java.sql.Connection getConnection(java.lang.String url)
throws java.sql.SQLException
DriverManager attempts to select an appropriate driver from
the set of registered JDBC drivers.url - a database url of the form
jdbc:subprotocol:subnamejava.sql.SQLException - if a database access error occurspublic abstract java.sql.Driver getDriver(java.lang.String url)
throws java.sql.SQLException
DriverManager attempts to select an appropriate driver from
the set of registered JDBC drivers.url - a database URL of the form
jdbc:subprotocol:subnameDriver object representing a driver that can connect
to the given URLjava.sql.SQLException - if a database access error occurspublic abstract java.util.Enumeration<java.sql.Driver> getDrivers()
Note: The classname of a driver can be found using
d.getClass().getName()
public abstract int getLoginTimeout()
public static DriverManager getInstance(java.lang.String libDir)
libDir - The library directory containing the JDBC drivers (actually the directory above a
directory 'jdbc4' containing the JDBC drivers).