Java Reference
In-Depth Information
15.2
I NTRODUCING JDBC
For many real-world applications, there are copious amounts of data associated
with them. Programmers first learn to store data into files, but serious applica-
tions require a database. Java programs can connect to and query a database
with the help of several Java classes which together make up the Java DataBase
Connectivity API, or JDBC.
With JDBC, your Java programs will be able to connect to databases any-
where on the network and to query data from the database with the simple
syntax that database programmers have been using for years—SQL.
JDBC provides an abstraction , a way to talk about the various aspects of
working with a database which is largely vendor-independent. Implementations
of JDBC can be, and are, built for many different databases and even other
data sources, such as flat files and spreadsheets.
The Linux environment offers several choices of databases, the two most
popular being MySQL and PostgreSQL. Both are Open Source projects avail-
able with most major Linux distributions, as well as online for downloading.
For many Java and Linux developers, however, the use of Java and Linux will
include their development environment and the servers to which they deploy
their applications, but the database to which they connect will still be the cor-
porate database. For most commercial applications this is an Oracle database,
the industry leader, and due to its major presence in the marketplace we will
use Oracle in our examples as well.
NOTE
JDBC interfaces are available for almost any commercial database with any
significant marketshare. See Section 15.9 for a URL that has a list of such
choices. Most of what you will learn in this chapter will apply regardless of the
database you connect to.
To make even the most basic use of JDBC, you must understand three
basic operations:
• First, establishing and tearing down connections to your database server
• Second, querying data
• Finally, reading up the results of that query
Search WWH ::




Custom Search