Explain the architecture of JDBC?

Java 8ProgrammingObject Oriented Programming

If you want to develop a Java application that communicates with a database, you should use JDBC API. A driver is the implementation of the said API; various vendors provide various drivers, you need to use a suitable driver with respect to the database you need to communicate with. The driver manager loads the driver and manages the driver.

Following are the components of JDBC:

  • JDBC DriverManager: The DriverManager class of the java.sql package manages different types of JDBC drivers. This class loads the driver classes. In addition to this whenever a new connection establishes it chooses and loads the suitable driver from the previously loaded ones.

    Note: From JDBC 4.0 the drivers in the CLASSPATH will be loaded automatically.

  • JDBC API: It is a Java abstraction which enables applications to communicate with relational databases. It provides two main packages namely, java.sql and javax.sql. It provides classes and methods to connect with a database, create statements (quires), execute statements and handle the results.

Updated on 30-Jul-2019 22:30:25