Introduction to JDBC

JDBC from JavaSoft is a Java API that is used to execute SQL statements. This API provides a set of common vendor-neutral classes and interfaces to enable database access to different databases from Java applications. You can access not only databases but also spreadsheets and flat files using this API. Also, you can use the JDBC API in various Java applications, whether JSPs, servlets, EJBs, or even pure Java applications.

The JDBC specification, first released in May 1996, is structurally and conceptually similar to Microsoft's ODBC (Open Database Connectivity) driver. ODBC is built upon the X/Open CLI specification.

JDBC is not a replacement for ODBC but an alternative method for accessing a database. This Java language API is platform independent because it runs on the JVM, whereas ODBC is a native interface, and calls to it must access native libraries (such as DLLs). JDBC is similar to the ActiveX Data Object (ADO) or Data Access Object (DAO) wrappers of ODBC, wherein no pointers are used to access the database, but an object-oriented method of using APIs is utilized.

Also, unlike ODBC drivers, JDBC drivers need not be installed on the client machine but can be downloaded from the server. Since this is possible, it is not necessary to install expensive proprietary software on the client machine.

The first version of the JDBC API, which was released around 1995, was JDBC version 1.x. The second major release, JDBC 2.x, had improved Array, BatchUpdateException, Blob, Clob, Ref, SQLData, SQLInput, SQLOutput, and Struct functions in the java.sql package.

JDBC 3.0 was released in February 2002. However, WebLogic 7.0 uses JDK 1.3.1, which supports JDBC 2.0.

JDBC has grown to be an alternative to data-retrieving CGI programs. JDBC also uses protocols other than the HTTP protocol, such as IIOP, TDS (Tabular Data Stream), and many other standards. Firewalls may not be configured to recognize native database protocols other than the HTTP protocol in an Internet environment. Hence, there may be problems in accessing a database through a firewall.

A JDBC application essentially consists of two layers:

  • The first layer is the JDBC API, which interacts with the JDBC driver.

  • The second layer is the JDBC driver, which interacts with the database management system (DBMS).

From Figure 7.1, you can see that there are four types of drivers in JDBC. However, these are all based on two models:

  • The two-tier model In the two-tier model, the Java application uses the JDBC API and the database server. The JDBC driver could be implemented in many ways: Either it could be downloaded onto the client as in an applet, or it could interact with the database using a protocol proprietary to the database.

  • The three-tier model The three-tier model involves a client, a middle tier, and the database. The middle tier acts like a proxy for the client, communicating with the database to perform the necessary transactions. The client interacts with the middle tier through various network protocols (such as HTTP), distributed computing protocols (such as RMI or CORBA), or a database-specific custom protocol. The middle tier may be the application server, on which the business logic could reside. The middle tier interacts with the database using a proprietary DBMS protocol.

Figure 7.1. Driver types and their uses.

graphics/07fig01.gif



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

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