July 1,2016
Today i come to know about the JDBC(Java Database Connection)& the connectivity.
Java JDBC
Java JDBC is a java API to connect and execute query with the database. JDBC API uses jdbc drivers to connect with the database.
Use of JDBC:
Before JDBC, ODBC API was the database API to connect and execute query with the database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses JDBC drivers (written in Java language).
JDBC Driver
JDBC Driver is a software component that enables java application to interact with the database.There are 4 types of JDBC drivers:
- JDBC-ODBC bridge driver
- Native-API driver (partially java driver)
- Network Protocol driver (fully java driver)
- Thin driver (fully java driver)
5 Steps to connect to the database in java
There are 5 steps to connect any java application with the database in java using JDBC. They are as follows:
- Register the driver class
- Creating connection
- Creating statement
- Executing queries
- Closing connection