Java can be used to access many kinds of databases. A database can be something as simple as a text file or a fast key/value pairing on disk (DBM format), as sophisticated as a relational database management system (DBMS), or as exotic as an object database.
Regardless of how your data is actually stored, in many
applications you'll want to write a class called an
accessor to mediate between the database and the
rest of the application. For example, if you are using JDBC, the answers
to your query come back packaged in an object called a
ResultSet, but it would not make sense to
structure the rest of your application around the
ResultSet because it's JDBC-specific. In a
Personal Information Manager application, for example, the primary
classes might be
Meeting. You would probably write a
PersonAccessor class to request the names and
addresses from the database (probably using JDBC) and generate
Address objects from them. The
DataAccessor objects would also take updates
from the main program and store them into the database.
Java DataBase Connectivity (JDBC) consists of classes in
java.sql and some JDBC Level 2 extensions in package
javax.sql. (SQL is the Structured Query
Language, used by relational database software to provide a standard
command language for creating, modifying, updating, and querying
Why was JDBC invented? Java is highly portable, but many databases previously ...