DriverManager class
It's used for establishing JDBC connections and for managing JDBC drivers. JDBC 2.0 API has a new interface DataSource and the preferred means of connecting to a data source has now become by using a DataSource object.
DriverManager tries to load the driver classes mentioned in the 'jdbc.drivers' system property while the initialization. You can explicitly load JDBC drivers at any time by using the 'Class.forName("driver class");'
syntax.
getConnection method of the DriverManager class tries to locate a suitable driver from amongst those loaded either during the initialization or by using Class.forName()
explicitly. On successful invocation, this method returns a Connection object. You need to specify the database url having the subprotocol & subname, user id, password, etc. If any error occours during the database access then a SQLException
is thrown.