Today’s websites are just not simple web pages; they do more than just providing static information. They need to be a dynamic, transactional and secure website. So, business builds Enterprise applications which consist of Business logic, and they provide much-advanced functionalities than just a static website.
Enterprise applications follow Model View Controller (MVC) structure. The front end can be made of any programming, scripting, etc. languages, whereas backend must act as the database for data storing. But the Java consists of objects and classes and database consists of tables with rows and columns. Java objects don’t understand the relational databases.
So, we need an underlying interface to interact these both languages. Hence, we use JDBC which is called Java Database Connectivity. For the client to have access to the database, an API which is application programming interface is designed based on Java which is called JDBC. It is introduced by the Oracle Corporation and is a part of Java SE, i.e., Standard Edition.
Using the front end in the website, clients can access any kind of data which is in a tabular form, stored in a RelationalDatabase through Java API. It is cross-platform compatible, which means it works on different operating systems such as UNIX, Windows, Mac, etc.
What is JDBC?
It is used for connectivity between a wide range of databases and the Java programming language which is used to build the front end using independent databases. It is a standard Java API.
There are many services and functions provided by the JDBC library and to support each of them it also has some APIs. Let us check out some of the tasks related to it, which needs association with the database.
• Connection to take place with the database.
• Creation and executing of the queries of SQL or MySQL in the database.
• Retrieving of the results from the database
• Modifying the obtained results of the record.
Fundamentally, for providing access to the underlying database in a portable way, a specification that allows us to do so by providing a set of interfaces within its library is JDBC. Various types of executables can be written using Java, some of them are −
• Applets and web applications designed using Java
• Java servlets
• JSPs i.e., Java Server Pages
• EJBs, i.e., Enterprise Java Beans For all of these executables to have the access to the data stored in the database, they are allowed to use JDBC driver which provides access to them.
Similar to ODBC, JDBC provides programs which are database-independent Java code. The difference is just that ODBC is written in Oracle whereas JDBC is especially designed for Java.
To implement this and create a web application using JDBC, you must have a better understanding towards MYSQL or SQL databases and programming in core Java.
JDBC Architecture
In general, for the database access, the JDBC API supports processing models in both two-tier and three-tier. Here is the JDBC architecture. It has these layers.