Different section of JDBC and their usage.

Explain the different section of JDBC and their usage.

JDBC consists of two parts:

JDBC API: it is a purely Java-based API.

JDBC Driver Manager, which communicates with vendor-specific drivers that perform the real communication with the database. The database servers like Oracle and SQL server have different data-types than Java like there is String data type in Java but in Oracle or SQL varchar, char is used as a string data-type.

There are four distinct type of drivers according to which four types of JDBC architecture is defined.

Type 1: JDBC-ODBC Driver

Type 1 drivers act as a bridge between JDBC and other database connectivity mechanism such as ODBC. This driver is included in the Java 2 SDK within the sun.jdbc.odbc package. In this driver the java statements are converted to a jdbc statement. JDBC statements call the ODBC by using the JDBC-ODBC Bridge. And finally the query is executed by the database. This driver has serious limitation for many applications.

1. Not fully written in Java hence not portable from one environment to another environment.
2. There are three layers in this driver hence it has slow performance. Each client must have its own ODBC installation.

Type 2: JDBC Native API

Type 2 drivers use the Java Native Interface (JNI) to make calls to a local database library API. This driver converts the JDBC calls into a database specific call for databases such as SQL, ORACLE etc. It is vendor specific driver. It is not portable. It is not fully written in Java. It is not thread-safe.

Type 3: All Java Driver

Type 3 drivers are pure Java drivers that use a proprietary network protocol to communicate with JDBC middleware on the server. The middleware then translates the network protocol to database-specific function calls. It is fully written in Java hence portable. It maintains transactions Client JDBC driver becomes small and hence loaded quickly. It provides facilities such as data caching, load balancing, logging and auditing. Using Type3 drivers one can use multiple Databases using a single driver which is not possible in other drivers so generally preferred in industries.

Type 4: Java to Database Protocol

Type 4 drivers are pure Java drivers that implement a proprietary database protocol (like Oracle's SQL*Net) to communicate directly with the database. They are the fastest JDBC drivers.

This driver directly converts the java statements to SQL statements.
Can you explain SQLException class? What is SQL State in SQL Exception
SQLException class - The SQLException Class and its subtypes provide information about errors and warnings that occurs when the data source is accessed...
CallableStatement interface
CallableStatement interface - It is an interface which is the sub interface of Statement Interface....
Batch updates using CallableStatement interface.
Batch updates using CallableStatement interface - Batch update is the ability to add more than one statement at once...
Post your comment