JDBC is a Java API. Itís an industry standard for database-independent connections from Java applications to tabular data stored in relational databases, flat files, or spreadsheets.
The JDBC API defines multiple interfaces, which must be implemented by the database vendors or a third party, and is supplied as a driver.
As shown in figure 3.71, you can think of the bridge between a Java application and a database to be made of the JDBC API and driver implementation classes.
The JDBC API provides your classes with the interfaces and classes to connect to a database and process the results. The actual classes that implement the interfaces in the JDBC API are defined by the
driver for a database.
JDBC API overview
By using the classes and interfaces from the JDBC API, Java classes can connect to a data source, execute SQL (Structured Query Language, the standard language for
relational database management systems, RDBMS), and process the results.
At the heart of the JDBC API lies the use of SQL to create, modify, and delete database objects like tables, and query and update them, as shown in figure 3.72.
JDBC provides vendor-neutral access to the common database features. So if you do not use proprietary features of a database, you can easily change the database that
you connect to. The JDBC API includes an abstraction of a database connection, statements, and result sets.
With the JDBC API, you have a choice of connecting to a local or remote data store either directly or through an application server.
The JDBC API supports the use of a two-tier model or n-tier (multiple-tier) model to connect to a database or data source.
In a two-tier model, your Java application connects directly with a local or remote data source using a JDBC driver.
In an n-tier model, a Java or non-Java application sends a command to an application
server, which connects to a remote or local database using the JDBC API.
JDBC drivers provided by the database or a third party work as interpreters to enable the Java applications to communicate with the databases.