JDBC API
In this tutorial, we are going to discuss about JDBC API.
- JDBC API provides several Classes and Interfaces.
- Programmer can use these Classes and Interfaces to communicate with the Database.
- Driver Software Vendor can use JDBC API while developing Driver software.
- JDBC API defines 2 Packages
1. java.sql Package
It contains basic Classes and Interfaces which can be used for Database Communication.
Interfaces
- Driver
- Connection
- Statement
- PreparedStatement
- CallableStatement
- ResultSet
- ResultSetMetaData
- DataBaseMetaData
Classes
- DriverManager
- Date
- Time
- TimeStamp
- Types
2. javax.sql Package
It defines more advanced Classes and Interfaces which can be used for Database Communication. There are multiple Sub Packages are also available
- javax.sql.rowset;Â
- javax.sql.rowset.serial;
- javax.sql.rowset.spi;
Interfaces
- DataSource
- RowSet
- RowSetListener
- ConnectionEventListener
- StatementEventListener
Classes
- ConnectionEvent
- RowSetEvent
- StatementEvent
- Programmers are not responsible to provide Implementation for JDBC API Interfaces.
- Most of the times Database Vendor is responsible to provide Implementation as the Part of Driver Software.
- Every Driver Software is a Collection of Classes implementing various Interfaces of JDBC API, which can be used to communicate with a particular Database.
- For Example, Driver Software of Oracle means Collection of Implementation Classes of JDBC API, which can be used to communicate with Oracle Database.
- Every Driver Software is identified with some Special Class which is nothing but Driver Class. It is the Implementation Class of Driver Interface present in. java.sql Package.
- As the Part of JDK, SUN People provided one Built-In Driver Software which implements JDBC API, which is nothing but Type-1 Driver (JDBC-ODBC Bridge Driver).
- The corresponding Driver Class Name is
Difference between Driver Interface, Driver Class and Driver Software
1. Driver Interface
- This Interface present in java.sql Package.
- This Interface acts as Requirement Specification to implement Driver Class.
2. Driver Class
It is the Implementation Class of Driver Interface
E.g: sun.jdbc.odbc.JdbcOdbcDriver
3. Driver Software
- It is the Collection of Implementation Classes of various Interfaces present in JDBC API.
- It acts as Bridge between Java Application and Database.
- It is responsible to convert Java Calls into Database specific Calls and Database specific Calls into Java Calls.
- Usually Driver Software’s are available in the Form of jar File.
Example
- ojdbc14.jar
- ojdbc6.jar
- ojdbc7.jar
- mysql-connector.jar etc.
Driver Softwares can be provided by the following Vendors
- Java Vendor (Until 1.7 Version Only)
- Database Vendor
- Third Party Vendor
- Type-1 Driver (JDBC-ODBC Bridge Driver) provided by Java Vendor.
- Thin Driver provided by Oracle Database Vendor.
- Inet is a Third Party Vendor and providing several Driver Software’s for different Databases.
Example
- Inet Oraxo For Oracle Database
- Inet Merlia For Microsoft SQL Server
- Inet Sybelux For Sybase Database
Note
- It is highly recommended to use Database Vendor provided Driver Software’s.
- While developing Driver Software, Vendors may use only Java OR Java with other Languages like C OR C++.
- If Driver Software is developed only in Java Language then such Type of Drivers are called Pure Java Drivers.
- If Driver Software developed with Java and other Languages, then such Type of Driver Softwares are called Partial Java Drivers.
That’s all about the JDBC API. If you have any queries or feedback, please write us email at contact@waytoeasylearn.com. Enjoy learning, Enjoy Java.!!
JDBC API