by Dinesh Thakur Category: Servlet with MySql Database

Below Figure is a representative sketch of the JDBC architecture. This can be used in Java applications,applets, servlets or any other program where Java codes used. Java codes only interact with theJDBC Application-Program Interface (API). The JDBC API is a simple SQL-Level interface,which allows execution of SQL statements through Java.

The API consists of a set of interfaces and classes designed to perform actions on a database. The JDBC API class DriverManager, which is used to establish the connection to the database, is responsible for managing the different JDBC drivers. Other classes of JDBC API are useful when the programmer wishes to develop specific drivers of her own. The JDBC-ODBC bridge performs translations of JDBC calls to an ODBC-compatible format. This bridge is required to maintain compatibility with non-JDBC databases.

                         The JDBC architecture

Interfaces in JDBC API

The JDBC API is defined in java.sql package and it consists of the following interfaces:

• The interface java.sqI.Environment, which allows the creation of new database connections.

• java.sql.Connection, which permits connecting to the database.

• java.sql.Statement, which is the container class for embedded SQL statements.

• java.sql.ResultSet, which allows accessing the results of a statement.

The different classes found in the JDBC API are listed below:

Driver                           • SqlException                 • Date

• Driver Manager          • SqlWarning                    • Time

• DriverPropertyInfo    • ResultSet                        • Timestamp

Connection                   ResultSetMetaData     • Types

Statement                     DatabaseMetaData     • DataTruncation



The implementation classes for the interfaces shown in italic, in the above list, are

database- vendor-specific.

Types of database driver

Database vendors can provide drivers of various types. Sun Microsystems have specified four types of driver:

Type l-Bridge Drivers These drivers use bridge technology like ODBC to connect to the database. The JDBC-ODBC Bridge Driver is the most commonly used driver.

Type 2-Part-Java Drivers This type wraps a thin layer of Java code over the native code libraries to implement JDBC.

Type 3-Network All-Java Drivers This type consists of a Java code which connects to middleware to access a database via a network protocol. Generally this type of driver is not used for data access.

Type4-Direct All-Java Drivers This type provides a pure Java JDBC implementation, which can be accessed directly and provides services to networking middleware. This is used mainly for internet applications.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles