JDBC overview

JDBC is a Java Database Connectivity API that lets you access virtually any tabular data source from a Java application.

In addition to providing connectivity to a wide range of SQL databases, JDBC allows you to access other tabular data sources such as spreadsheets or flat files.

Although JDBC is often thought of as an acronym for Java Database Connectivity, the trademarked API name is actually JDBC.

JDBC defines a low-level API designed to support basic SQL functionality independently of any specific SQL implementation. This means the focus is on executing raw SQL statements and retrieving their results.

JDBC is based on the X/Open SQL Call Level Interface, an international standard for programming access to SQL databases, which is also the basis for Microsoft's ODBC interface.

The JDBC 2.0 API includes two packages: java.sql, known as the JDBC 2.0 core API and javax.sql, known as the JDBC Standard Extension. Together, they contain the necessary classes to develop database applications using Java.

As a core of the Java 2 Platform, the JDBC is available on any platform running Java. The JDBC 3.0 Specification, released in October 2001, introduces several features, including extensions to the support of various data types, additional MetaData capabilities, and enhancements to a number of interfaces.

The JDBC Extension Package (javax.sql) was introduced to contain the parts of the JDBC API that are closely related to other pieces of the Java platform that are themselves optional packages, such as the Java Naming and Directory Interface (JNDI) and the Java Transaction Service (JTS).

In addition, some advanced features that are easily separable from the core JDBC API, such as connection pooling and rowsets, have been added to javax.sql. Putting these advanced facilities into an optional package instead of into the JDBC 2.0 core API helps to keep the core JDBC API small and focused.

The main strength of JDBC is that it is designed to work in exactly the same way with any relational database. In other words, it isn't necessary to write one program to access an Oracle database, another to access a Sybase database, another for SQL Server, and so on. JDBC provides a uniform interface on top of a variety of different database-connectivity modules.

The three main functions of JDBC are as follows:

  • Establishing a connection with a database or other tabular data source
  • Sending SQL commands to the database
  • Processing the results

Two-Tier and Three-Tier Models

The JDBC API supports both two-tier and three-tier models for database access. In other words, JDBC can either be used directly from your application or as part of a middle-tier server application.

Two-Tier Model

In the two-tier model, a Java application interacts directly with the database.

Functionality is divided into these two layers:

  • Application layer, including the JDBC driver, business logic, and user interface
  • Database layer, including the RDBMS

The interface to the database is handled by a JDBC driver appropriate to the particular database management system being accessed. The JDBC driver passes SQL statements to the database and returns the results of those statements to the application.

Three-tier Model

In the three-tier model, commands are sent to an application server, forming the middle tier. The application server then sends SQL statements to the database.

The database processes the SQL statements and sends the results back to the application server, which then sends them to the client. These are some advantages of three-tier architecture:

  • Performance can be improved by separating the application server and database server.
  • Business logic is clearly separated from the database.
  • Client applications can use a simple protocol such as CGI to access services.

Our VPS servers come with pre-installed MySQL, Tomcat and jdbc configuration. So you might want to save the trouble and review VPS hosting offer

The three-tier model is common in Web applications, where the client tier is frequently implemented in a browser on a client machine, the middle tier is implemented in a Web server with a servlet engine, and the database management system runs on a dedicated database server.

Contact sales!