DriverManager class

  • DriverManager class acts as basic service for managing a set of JDBC drivers
  • DriverManager.getConnection methods returns the Connection object to the supplied database
  • DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers
  • Driver must be present in the classpath so that it can be loaded using Class.forName(driverClassName)
  • Since JDBC 4.0, Applications no longer need to explicitly load JDBC drivers using Class.forName()
  • Existing programs which currently load JDBC drivers using Class.forName() will continue to work without modification

Commonly used methods of DriverManager class

  • static void registerDriver(Driver driver)
    - Registers the given driver with the DriverManager.
  • static void deregisterDriver(Driver driver)
    - Removes the specified driver from the DriverManager's list of registered drivers.
  • 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 Connection getConnection(String url, String user, String password)
    - Attempts to establish a connection to the given database URL.
  • static Driver getDriver(String url)
    - Attempts to locate a driver that understands the given URL.
  • static Enumeration getDrivers()
    - Retrieves an Enumeration with all of the currently loaded JDBC drivers to which the current caller has access.
Footer with Map