In this tutorial we shall learn, what is JDBC API and different types of JDBC Drivers which are used to connect Java based Web applications, desktop applications and mobile applications with different types of Database servers like MS Database server, MS Access, MySQL Server, Sybase database server, Oracle Database servers and cloud databases etc.
What is JDBC API:JDBC stands for "Java Database Connectivity. JDBC is standard Java API for providing database independent connectivity between the Java applications and different types of databases. The
JDBC API contains number of interfaces and classes that are extensively helpful while
communicating with a database.JDBC technology support java developers to use java in applications for write once and run anywhere capabilities.
- Used to establish a connection with a database of different vendors.
- Used to send SQL statements (create, update, delete, insert etc) to database
- Used to process the accessed results
JDBC Driver TypesThere are four types or levels of JDBC Driver. Each type is used to define a JDBC driver implementation with respect to Database Type, platform independence, performance, deployment and administration.
- JDBC - ODBC Bridge
- Native - API / partly Java driver
- Net - protocol / all-Java driver
- Native - protocol / all-Java driver
1- JDBC - ODBC BridgeJDBC - ODBC Bridge type is generally used to connect java database driven applications with Microsoft databases like MS Access and MS SQL Server. It first translates all JDBC calls into ODBC (Open Database Connectivity) calls and then send them to the ODBC Driver which is further used for communicating with databases. Due to this reason, this type of driver performance is degraded
Native - API/partly Java driverPartly-Java drivers use Java Native Interface to communicate with database-specific API which may be written in C/C++. This type, first converts JDBC calls into database specific calls such as SQL Server, Informix, Oracle or Sybase. Its performance is significantly better than the JDBC-ODBC bridge.
Net - protocol / all-Java driver
As showing in below diagram, this JDBC Driver type follows a three-tiered approach to connect with database server whereby the JDBC requests () are passed through via middle-tier server. The Pure Java application client first send requests to middle ware server which is not database specific server, it translates requests into a database-specific protocol and then send it to Database server. If the middle-tier server is written in pure java language, then type 1or type 2 JDBC driver can be used to do this
Native - protocol / all-Java driverThis type of JDBC Driver is completely implemented in Java language to achieve platform independence and for elimination of deployment issues. It converts JDBC calls directly into the vendor specific DBMS protocol which enable the java client application to communicate directly with the database server. This type of driver Performance is very good as compare to other types.
1- The JDBC API is simple to learn. Developers can easily learn JDBC and use it efficiently in their database driven java applications. It is easy to deploy and is inexpensive to maintain it.
2- JDBC technology make possible for leveraging of existing enterprise data and save businesses to lock if it was previously using any proprietary architecture, business can continue to use and access their installed existing databases easily even database stored on different DBMS Software. .
3- Using Java API and the JDBC API, enterprise database driven custom applications development has become simplified, easy and economical. Because JDBC hides the complexity of many data access tasks and provides easily methods to access the databases. It makes the applications to easy to deploy and their maintenance less expensive.
4- By using JDBC API, there is almost zero configuration for network client computers which supports the network computing paradigm and centralizes software maintenance.
5- JDBC Drive has bettor support to connect java applications with cloud databases.