Java Reference
In-Depth Information
Chapter 7
Java Database Connectivity (JDBC)
Learning Objectives
After reading this chapter, you should:
￿ be aware of what JDBC is and why it is needed;
￿ be aware of the differing versions of JDBC that are associated with the differing
versions of Java;
￿ know how to use JDBC to make a connection to a database by employing Java's
DriverManager class;
￿ know how to make use of the JDBC-ODBC bridge driver;
￿ know how to use JDBC to execute SQL queries and updates and how to handle
the results returned;
￿ know how to use Apache Derby/Java DB to create and manipulate a relational
database table;
￿ know how to carry out transaction processing via JDBC;
￿ know how to use JDBC to fi nd out structural information about databases;
￿ know how to make use of a JTable to format the results of a database query;
￿ know how to use JDBC to move freely around the rows returned by a query;
￿ know how to use JDBC to modify databases via Java methods;
￿ know how to use JDBC to make a connection to a database by employing Java's
DataSource interface;
￿ be aware of the advantages that the use of the DataSource interface has over the
use of the DriverManager class.
The previous three chapters employed individual, 'fl at' fi les to provide persistent
data storage. Nowadays, of course, most organisations have the bulk of their data
structured into databases , which often need to be accessed from more than one site.
These databases are almost invariably relational databases. Programs written in
Java are able to communicate with relational databases (whether local or remote)
via the Java Database Connectivity (JDBC) API, which became part of the core Java
distribution with JDK 1.1. In this chapter, we shall consider how such databases
may be accessed via JDBC.
Search WWH ::




Custom Search