JDBC  «Prev 

JDBC DriverManager Connection

1) Load the JDBC Driver object by calling Class.forName(driver).newInstace();   In the main() method of your application; or better, in a static initializer block in one of your classes
1) Load the JDBC Driver object by calling Class.forName(driver).newInstace(); In the main() method of your application; or better, in a static initializer block in one of your classes.

2) To start the JDBC Connection Process, you need the database URL, user ID, and password.
2) To start the JDBC Connection Process, you need the database URL, user ID, and password.

3) Request a java.sql.Connection ojbect from the DriverManager. This request will lead to a search performed by the DriverManager
3) Request a java.sql.Connection object from the DriverManager. This request will lead to a search performed by the DriverManager

4) The DriverManager searchs through all known java.sql.Driver implementations for the one that connects with the URL you specified in step 1.
4) The DriverManager searchs through all known java.sql.Driver implementations for the one that connects with the URL you specified in step 1. The DriverManager keeps a list of classes that implement the java.sql.Driver Interface. JDBC requires the Driver class to register itself (or be registered)

5) The DriverManager reports the results of the search. One of two things can occur: the DriverManager may or may not find a match.
5) The DriverManager reports the results of the search. One of two things can occur: the DriverManager may or may not find a match. If it does not find a match, DriverManager throws an exception back to your application.

6) If the DriverManager finds a driver that it can connect after your URL is recognized, the Driver creates a database connection using the properties specified in your code
6) If the DriverManager finds a driver that it can connect after your URL is recognized, the Driver creates a database connection using the properties specified in your code.

7) Once the database connection is created, the Driver provides the DriverManager with an instance of java.sql.Connection.
7) Once the database connection is created, the Driver provides the DriverManager with an instance of java.sql.Connection. This represents the database connection.

8) The Connection object is passed back to the application by the DriverManager.
8) The Connection object is passed back to the application by the DriverManager. The application can now use the Connection object to create Statement object to query the database.