It would be appropriate at this point of time to introduce terms such as Data Source andDatabase or DBMS before proceeding further. Even though the word database is in thename JDBC, the form, content, and location of the data is immaterial to the Java programusing JDBC so long as there is a driver for that data. Hence the notation data source todescribe the data is more accurate than Database, DBMS, DB, or just file. In the future,Java devices such as televisions, answering machines, or network computers will access,retrieve, and manipulate different types of data (audio, video, graphics, time series, andso on) from various sources that are not relational databases at all! And much of the datamight not even come from mass storage. For example, the data could be video streamfrom a satellite or audio stream from a telephone.
1.1.1 How does JDBC Work?
The JDBC defines a set of API objects and methods to interact with the underlying database. AJava program first opens a connection to a database, makes a statement object, passes SQLstatements to the DBMS through the statement object and retrieves the results as well asinformation about the result sets. Typically, the JDBC class files and the Java applet/applicationreside in the client and also they could be downloaded from the network. For the fast execution, itis desirable to have the JDBC classes in the client. In contrast, the DBMS and the data source aretypically located in a remote server. The JDBC classes are in the java.sql package and all Java programs use the objects and methods in the java.sql package to read from and write to datasources. A program using the JDBC will require a driver for the data source with which it wantsto interface. This driver can be a native module or it can be a Java program that talks to a server in the network using some RPC or a HTTP talker-listener protocol. It is conceivable that anapplication will deal with more than one data source-possibly heterogeneous data sources. For this reason, JDBC has a DriverManager whose function is to manage the drivers and provide alist of currently loaded drivers to the application programs.
1.1.2 JDBC Classes - Overview
When you look at the class hierarchy and methods associated with it, the topmost class in thehierarchy is the DriverManager. The DriverManager keeps the driver information, stateinformation, and more. When each driver is loaded, it registers with the DriverManager andselects the appropriate driver depending on the JDBC URL. The JDBC identifies a database with