Android
java.sql
public class

java.sql.DriverManager

java.lang.Object
java.sql.DriverManager

Provides facilities for managing JDBC Drivers.

The DriverManager class will load JDBC drivers during its initialization, from the list of drivers referenced by the System Property "jdbc.drivers".

Summary

Public Methods

      static    void  deregisterDriver(Driver driver)
Removes a driver from the DriverManager's registered driver list.
      static    Connection  getConnection(String url, String user, String password)
Attempts to establish a connection to the given database URL.
      static    Connection  getConnection(String url)
Attempts to establish a connection to the given database URL.
      static    Connection  getConnection(String url, Properties info)
Attempts to establish a connection to the given database URL.
      static    Driver  getDriver(String url)
Tries to find a driver that can interpret the supplied URL.
      static    Enumeration<Driver getDrivers()
Returns an Enumeration that contains all of the loaded JDBC drivers that the current caller can access.
      static    PrintStream  getLogStream()
This method is deprecated. Gets the log PrintStream used by the DriverManager and all the JDBC Drivers.
      static    PrintWriter  getLogWriter()
Retrieves the log writer.
      static    int  getLoginTimeout()
Returns the login timeout when connecting to a database, in seconds.
      static    void  println(String message)
Prints a message to the current JDBC log stream.
      static    void  registerDriver(Driver driver)
Registers a given JDBC driver with the DriverManager.
      static    void  setLogStream(PrintStream out)
This method is deprecated. Sets the Print Stream to use for logging data from the DriverManager and the JDBC drivers.

Use setLogWriter(PrintWriter) instead.

      static    void  setLogWriter(PrintWriter out)
Sets the PrintWriter that will be used by all loaded drivers, and also the DriverManager.
      static    void  setLoginTimeout(int seconds)
Set the login timeout when connecting to a database, in seconds.
Methods inherited from class java.lang.Object

Details

Public Methods

public static void deregisterDriver(Driver driver)

Removes a driver from the DriverManager's registered driver list. This will only succeed where the caller's classloader loaded the driver that is to be removed. If the driver was loaded by a different classloader, the removal of the driver will fail silently.

If the removal succeeds, the DriverManager will not in future use this driver when asked to get a Connection.

Throws

SQLException if there is an exception accessing the database.

public static Connection getConnection(String url, String user, String password)

Attempts to establish a connection to the given database URL.

Parameters

url a URL string representing the database target to connect with
user a userid used to login to the database
password a password for the userid to login to the database

Returns

  • a Connection to the database identified by the URL. null if no connection can be made.

Throws

SQLException if there is an error while attempting to connect to the database identified by the URL

public static Connection getConnection(String url)

Attempts to establish a connection to the given database URL.

Parameters

url a URL string representing the database target to connect with

Returns

  • a Connection to the database identified by the URL. null if no connection can be made.

Throws

SQLException if there is an error while attempting to connect to the database identified by the URL

public static Connection getConnection(String url, Properties info)

Attempts to establish a connection to the given database URL.

Parameters

url a URL string representing the database target to connect with
info a set of Properties to use as arguments to set up the connection. Properties are arbitrary string/value pairs. Normally, at least the properties "user" and "password" should be passed, with appropriate settings for the userid and its corresponding password to get access to the database concerned.

Returns

  • a Connection to the database identified by the URL. null if no connection can be made.

Throws

SQLException if there is an error while attempting to connect to the database identified by the URL

public static Driver getDriver(String url)

Tries to find a driver that can interpret the supplied URL.

Parameters

url the URL of a database

Returns

  • a Driver that can understand the given URL. null if no Driver understands the URL

Throws

SQLException if there is any kind of Database Access problem

public static Enumeration<Driver> getDrivers()

Returns an Enumeration that contains all of the loaded JDBC drivers that the current caller can access.

Returns

  • An Enumeration containing all the currently loaded JDBC Drivers

public static PrintStream getLogStream()

This method is deprecated. Gets the log PrintStream used by the DriverManager and all the JDBC Drivers.

Returns

  • the PrintStream used for logging activity

public static PrintWriter getLogWriter()

Retrieves the log writer.

Returns

  • A PrintWriter object used as the log writer. null if no log writer is set.

public static int getLoginTimeout()

Returns the login timeout when connecting to a database, in seconds.

Returns

  • the login timeout in seconds

public static void println(String message)

Prints a message to the current JDBC log stream. This is either the PrintWriter or (deprecated) the PrintStream, if set.

Parameters

message the message to print to the JDBC log stream

public static void registerDriver(Driver driver)

Registers a given JDBC driver with the DriverManager.

A newly loaded JDBC driver class should register itself with the DriverManager by calling this method.

Parameters

driver the Driver to register with the DriverManager

Throws

SQLException if a database access error occurs.

public static void setLogStream(PrintStream out)

This method is deprecated. Sets the Print Stream to use for logging data from the DriverManager and the JDBC drivers.

Use setLogWriter(PrintWriter) instead.

Parameters

out the PrintStream to use for logging.

public static void setLogWriter(PrintWriter out)

Sets the PrintWriter that will be used by all loaded drivers, and also the DriverManager.

Parameters

out the PrintWriter to be used

public static void setLoginTimeout(int seconds)

Set the login timeout when connecting to a database, in seconds.

Parameters

seconds seconds until timeout. 0 indicates wait forever.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48