Java Reference
In-Depth Information
JDBC is not an acronym, but rather a trademarked name, although you
will commonly hear it referred to as Java Database Connectivity. The term
JDBC evolved from the acronym ODBC, which stands for Open Database
Connectivity, a technology designed to simplify database programming by
making the code to access a database independent of the actual
database used.
JDBC provides the same capabilities as ODBC, allowing Java programs to
contain database-independent code. This means that a Java program that
accesses a database is not only portable across JVMs (since it's a Java
program), but portable across databases, since it uses JDBC.
The JDBC API provides a mechanism for Java code to be portable across
databases. JDBC simplifies the creation and execution of Structured Query
Language (SQL) statements. SQL is a language used to communicate with a
database and access its contents. Be sure to read the upcoming section An SQL
Primer later in this chapter if you are new to SQL.
Classroom Q & A
Q: It seems impressive that a Java program can move from one data-
base to another without changing any of the code that involves
accessing the database. Does this really happen in the real world?
A: Well, yes and no. If you write a Java application that uses JDBC,
and you stick to the standard SQL statements, yes. If you write a
program that takes advantage of the unique features of a particu-
lar database, no. Keep in mind that this lack of portability is not a
Java or JDBC issue, but a database issue. In the competitive data-
base market, unique features or behaviors of a database are com-
mon. Any code in any language that takes advantage of a specific
feature of a database will not be portable across databases.
Q: Suppose my program uses everyday SQL, nothing fancy. How
is it possible that my program can communicate with different
databases?
A: The answer is based on having a JDBC driver. Before you can
access a database using JDBC, you need a JDBC driver for that par-
ticular database. For example, in this chapter I will show you how
to access a Microsoft Access database. This means that we will
need a JDBC driver for Access. We will just happen to use a driver
that comes with the J2SE.
Search WWH ::




Custom Search