JDBC, or Java Database Connectivity, is a Java API used to establish a connection and carry out a database query. The Sun Microsystems definition offers a common abstraction (API or Protocol) for Java Programmers to interface with different databases. It offers java database connectivity standards for the language. It is employed in the creation of Programmer needed to access databases. Both databases and spreadsheets can be accessed using JDBC and the database driver. With the use of JDBC APIs, business data kept in a relational database (RDB) can be accessed.
JDBC definition (Java Database Connectivity)
Java programming uses the JDBC API (Application Programming Interface) to communicate with databases. The JDBC classes and interfaces enable the application to transmit user requests to the designated database.
Purpose of JDBC
Databases must be accessed by enterprise apps built using the JAVA EE technology in order to store data specific to each application. Therefore, effective database connectivity is needed in order to interact with a database. This can be done by using the ODBC(Open database connectivity) driver. To interface or connect with different types of databases, including Oracle, MS Access, My SQL and SQL Server databases, this driver is utilized with JDBC.
Components of JDBC or Java Database Connectivity
JDBC typically has four primary parts that it uses to communicate with databases. They are listed as follows:
1.JDBC API: It offers a range of techniques and interfaces for simple database communication. These two packages, which contain the Java SE and Java EE platforms to demonstrate WORA (write once run anywhere) capabilities, are provided by the software.
2.JDBC Driver Manager: It loads a driver unique to a given database in an application to connect to that database. To handle the user request, it is used to call the database specifically for that database.
3.JDBC Test Suite: It’s used to test the actions (such insertion, deletion, and updating) that JDBC Drivers take.
Database drivers are linked to the database through JDBC-ODBC bridge drivers. This bridge converts ODBC function calls to JDBC method calls. It takes use of the native library for various characters included in the Sun.Jdbc.Odbc package.
Structure Components of JDBC
Application connects to a data source via a java applet or servlet.
Java Programmes can execute SQL commands and obtain results via the JDBC API. The following list includes some of the significant classes and interfaces included in JDBC API:
Driver Manager: In the JDBC architecture, it is significant. Enterprise applications are successfully connected to databases using some drivers designed specifically for databases.
Drivers for JDBC A JDBC driver that interacts intelligently with the relevant data source is required in order to communicate with a data source using JDBC.
Architecture of JAVA JDBC
Two Tiered Structure: A Java Programmers interfaces directly with the data source in a two-tiered architecture. The JDBC driver makes it possible for the application and data source to communicate. When a user submits a query to a data source, the data source responds with results that are provided back to the user.
The data source may be on a different computer connected to the user’s network. In a client/server configuration, the system used by the user serves as the client while the machine running the data source serves as the server.
Three-tier model: In this architecture, the user’s commands are transferred from middle-tier services back to the data source. The middle tier receives the results and relays them to the user.
Management information system directors find models of this kind to be very helpful.
Operation of JDBC
JDBC Driver supporting data sources like Oracle and SQL Server must be added in Java applications for JDBC support, which can be done dynamically at run time. Java applications that need to communicate with databases must be programmed using JDBC API. This JDBC driver communicates the relevant data source in an intelligent manner.