Java Reference
In-Depth Information
Oracle's Web page. Alternately, other database systems (such as Oracle, SQL Server, or
MySQL) will also work with Java, but they will require appropriate drivers and minor
changes to the source code. These changes are primarily in the specification of the
connection string.
Installing Derby may require some additional configuration of your system. It will
require setting several environment variables in your operating system. The DERBY_
INSTALL variable should be set to the pathname of the folder that contains the installed
Derby files, the CLASSPATH variable should include derby.jar , which is in the lib
folder of the main Derby folder, and your PATH variable should contain the bin folder
of the main Derby folder. See the documentation that comes with the Derby software
for more detailed instructions.
Derby runs in one of two modes: network server mode or embedded mode. In
network server mode, the Derby server program stores and processes the data while a
client program connects to the server using sockets. Queries, commands, and results are
transmitted between the client and server over sockets. This mode allows the database
server to run on one machine, while database clients run on separate machines. In
embedded mode, the classes for the Derby engine are embedded in your program
and executed in the same thread as your application. In this section, we will only use
embedded mode, but only minor changes are required to create a program that runs
under server mode.
Application programs typically access databases through several layers of abstraction.
The lowest level is the database engine, which handles tasks such as indexing, storing,
and retrieving data from the disk drive. In our case, these tasks are performed by the
Derby engine. A set of higher-level classes provides a connection to Derby along with
a consistent interface so that few code changes are necessary at higher levels if the
underlying database provider is changed. Java Database Connectivity ( JDBC ) is a
common API used to access databases. JDBC is included in version 5 or higher of
the Java SDK. Various Microsoft and Oracle database systems are among the many
commercially available database systems that are compatible with JDBC, along with
Derby. Typically, you need to download and install a JDBC driver for your database
system. Conceptually, JDBC is simple: Establish a connection to a database system
(either on your computer or over the Internet) and execute database commands, and
do this all within your Java code.
Finally, applications send commands and queries to JDBC using strings formatted
in SQL . SQL is a standard for database access that has been adopted by virtually all
relational database vendors. The initials SQL stand for Structured Query Language .
Display 19.9 illustrates the relationships among these components for an embedded
Derby database.
SQL
 
Search WWH ::




Custom Search