INTRODUCTION TO JAVA DATABASE CONNECTIVITY

INTRODUCTION TO JAVA DATABASE CONNECTIVITY

JDBC is Java application programming interface that allows the Java programmers to access database management system from Java code.
It is developed by JavaSoft, a subsidiary of Sun Microsystems.
Java Database Connectivity in short called as JDBC. It is a java API which enables the java programs to execute SQL statements. It is an application programming interface that defines how a java programmer can access the database in tabular format from Java code using a set of standard interfaces and classes written in the Java programming language.
JDBC has been developed under the Java Community Process that allows multiple implementations to exist and be used by the same application. JDBC provides methods for querying and updating the data in Relational Database Management system such as Access, SQL, Oracle etc.
The Java application programming interface provides a mechanism for dynamically loading the correct Java packages and drivers and registering them with the JDBC Driver Manager that is used as a connection factory for creating JDBC connections which supports creating and executing statements such as SQL INSERT, UPDATE and DELETE. Driver Manager is the backbone of the jdbc architecture.
Generally all Relational Database Management System supports SQL and we all know that Java is platform independent, so JDBC makes it possible to write a single database application that can run on different platforms and interact with different Database Management Systems.
Java Database Connectivity is similar to Open Database Connectivity (ODBC) which is used for accessing and managing database, but the difference is that JDBC is designed specifically for Java programs, whereas ODBC is not depended upon any language.
In short JDBC helps the programmers to write java applications that manage these three programming activities:
1. It helps us to connect to a data source, like a database.
2. It helps us in sending queries and updating statements to the database and
3. Retrieving and processing the results received from the database in terms of answering to your query.
Consider a scenario, where you have to develop an application for an Airlines Company to maintain a record of daily transactions. You install SQL Server, design the Airlines database, and ask Airlines personnel to use it. Will the database alone be of any use to the Airlines personnel?
The answer is NO! The task of updating the data in SQL server by using SQL statements alone will be a tedious process. An application will need to be developed that is user friendly and provides a client, the option to retrieve, add, and modify data at the touch of key.
Thus you need to develop an application that communicates with a database to perform the following tasks:
1. Store and update the data in the database.
2. Retrieve the data stored in the database and present it to the user in a proper format.
JDBC Components
JDBC has four Components:
1. The JDBC API.
2. The JDBC Driver Manager.
3. The JDBC Test Suite.
4. The JDBC-ODBC Bridge.
1. The JDBC API.
The JDBC application programming interface provides the facility for accessing the relational database from the Java programming language. The API technology provides the industrial standard for independently connecting Java programming language and a wide range of databases. The user not only execute the SQL statements, retrieve results, and update the data but can also access it anywhere within a network because of it’s “Write Once, Run Anywhere” (WORA) capabilities.
Due to JDBC API technology, user can also access other tabular data sources like spreadsheets or flat files even in the a heterogeneous environment. JDBC application programming interface is a part of the Java platform that have included Java Standard Edition (Java SE ) and the Java Enterprise Edition (Java EE) in itself.
The JDBC API has four main interface:
The latest version of JDBC 4.0 application programming interface is divided into two packages
i-) java.sql
ii-) javax.sql.
Java SE and Java EE platforms are included in both the packages.
2. The JDBC Driver Manager.
The JDBC Driver Manager is a very important class that defines objects which connect Java applications to a JDBC driver. Usually Driver Manager is the backbone of the JDBC architecture. It’s very simple and small that is used to provide a means of managing the different types of JDBC database driver running on an application. The main responsibility of JDBC database driver is to load all the drivers found in the system properly as well as to select the most appropriate driver from opening a connection to a database. The Driver Manager also helps to select the most appropriate driver from the previously loaded drivers when a new open database is connected.
3. The JDBC Test Suite.
The function of JDBC driver test suite is to make ensure that the JDBC drivers will run user’s program or not . The test suite of JDBC application program interface is very useful for testing a driver based on JDBC technology during testing period. It ensures the requirement of Java Platform Enterprise Edition (J2EE).
4. The JDBC-ODBC Bridge.
The JDBC-ODBC bridge, also known as JDBC type 1 driver is a database driver that utilize the ODBC driver to connect the database. This driver translates JDBC method calls into ODBC function calls. The Bridge implements Jdbc for any database for which an Odbc driver is available. The Bridge is always implemented as the sun.jdbc.odbc Java package and it contains a native library used to access ODBC.
Now we can conclude this topic: This first two component of JDBC, the JDBC API and the JDBC Driver Manager manages to connect to the database and then build a java program that utilizes SQL commands to communicate with any RDBMS. On the other hand, the last two components are used to communicate with ODBC or to test web application in the specialized environment.