JDBC is an J2SE application. Java Database Connectivity (JDBC) is used to transfer data from client application to database.
There will be two layers in the chain process
- Application Layer
- Database Layer
JDBC API used as an connection between the application layer and database layer.
As the application layer is written with java code or any other code and database layer will be in the form of queries and all. So API makes translation easy from application layer to database layer.
The communication from the client application to database is occured through installing drivers of database. Each database has its respective drivers.
Tasks of JDBC
- Making connection between database and application
- View or Modifying the records or data in DB
- Executing statements or queries
- Import JDBC Packages: Add import statements to your Java program to import required classes in your Java code.
- Register JDBC Driver: This step causes the JVM to load the desired driver implementation into memory so it can fulfill your JDBC requests.
- Database URL Formulation: This is to create a properly formatted address that points to the database to which you wish to connect.
- Create Connection Object: Finally, code a call to the DriverManagerobject's getConnection( ) method to establish actual database connection.
Types of Drivers
- JDBC-ODBC Bridge driver
- Native-API driver
- Network third party driver
- Thin / Pure Java driver