Chapter 5: Getting Started with JDBC

This chapter discusses the mechanisms used by Java Database Connectivity (JDBC), its programming interfaces, and some typical uses of JDBC.

JDBC is a set of programming interfaces. In this chapter, I discuss which Application Programming Interfaces (APIs) are of interest to database application developers.

The JDBC Mechanisms

The two major components of JDBC are the JDBC API and the JDBC Driver API. As Figure 5-1 shows, the JDBC API is a programming interface for database applications developers, whereas the JDBC Driver API is a lower-level programming interface for developers of specific drivers. I focus on the JDBC API.

click to expand
Figure 5-1: The JDBC APIs.

To write a successful database application with the Java Language Environment and JDBC, you must take certain steps. These steps are similar to those taken by C programmers using a call level interface (CLI).

The first step is to create a method for connecting to the database, equivalent to a connection context, associated with a specific database driver. Eventually, parameters are provided to locate a specific database, to enable sign-on as a recognized user giving identification and authentication, and to target a specific database managed by the database management system (DBMS). After a connection is established, various actions are allowed, such as closing the connection and sending queries, updates, and any kind of SQL statement, including requests to execute a precompiled SQL statement and stored procedures. Of course, a mechanism to access the result set is also provided. Figure 5-2 depicts the basic actions performed on the client and database sides.

click to expand
Figure 5-2: Actions performed on the client and DBMS sides.

A mechanism to handle errors is also provided. Exception management addresses this issue in Java by enabling the developer to call specific procedures after an error occurs.

The next section describes JDBC API interfaces in greater detail.



JDBC 3. 0. JAVA Database Connectivity
JDBC 3: Java Database Connectivity
ISBN: 0764548751
EAN: 2147483647
Year: 2002
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net