Java provides a mechanism for handling database known as JDBC. Using JDBC it is possible to commun
Java provides a mechanism for handling database known as JDBC. Using JDBC it is possible to communicate with a wide variety of database management system using SQL. JDBC is a programming interface between Java programs and database management system.
Java application calls the JDBC library. JDBC loads a driver which talks to the database. We can change database engines without changing database code.
A program uses a Java class known as JDBC driver to connect to a database. A special JDBC driver, known as JDBC-ODBC bridge, makes it possible to a vast number of ODBC drivers usable from JDBC.
The main advantage of JDBC is it provides a standard interface to all database management system.
There is four basic steps required to work with JDBC. The four steps are as follows:
1. Load a JDBC driver for your DBMS. This involves a statement Class.forName(), specifying the driver class name.
2. Use the driver to open a connection to a particular database.
3. Issue SQL statements through the connection. Once the connection established, it can be used to create objects through which SQL commands can be made.
4. Process result sets required by the SQL operations.
An application programming interface (API) is an interface implemented by a software program to enable interaction with other software, much in the same way that a user interface facilitates interaction between humans and computers.
The Java API is the set of classes included with the Java Development Environment. These classes are written using the Java language and run on the JVM. The Java API includes everything from collection classes to GUI classes.
The JDBC API is a Java API for accessing virtually any kind of tabular data. The JDBC API consists of a set of classes and interfaces written in the Java programming language that provide a standard API for tool/database developers and makes it possible to write industrial-strength database applications entirely in the Java programming language.
The JDBC API makes it easy to send SQL statements to relational database systems and supports all dialects of SQL. But the JDBC API goes beyond SQL, also making it possible to interact with other kinds of data sources, such as files containing tabular data.