Introduction to Java Programming-Comprehensive Version (6th Edition)
Chapter Summary
-
This chapter introduced the concepts of database systems, relational databases, relational data models, data integrity, and SQL. You learned how to develop database applications using Java.
-
The Java API for developing Java database applications is called JDBC . JDBC provides Java programmers with a uniform interface for accessing and manipulating a wide range of relational databases.
-
The JDBC API consists of classes and interfaces for establishing connections with databases, sending SQL statements to databases, processing the results of SQL statements, and obtaining database metadata.
-
Since a JDBC driver serves as the interface to facilitate communications between JDBC and a proprietary database, JDBC drivers are database-specific . A JDBC-ODBC bridge driver is included in JDK to support Java programs that access databases through ODBC drivers. If you use a driver other than the JDBC “ODBC bridge driver, make sure it is on the classpath before running the program.
[Page 1120] -
Four key interfaces are needed to develop any database application using Java: Driver , Connection , Statement , and ResultSet . These interfaces define a framework for generic SQL database access. The JDBC driver vendors provide implementation for them.
-
A JDBC application loads an appropriate driver using the Driver interface, connects to the database using the Connection interface, creates and executes SQL statements using the Statement interface, and processes the result using the ResultSet interface if the statements return results.
-
The PreparedStatement interface is designed to execute dynamic SQL statements with parameters. These SQL statements are precompiled for efficient use when repeatedly executed.
-
Database metadata is information that describes the database itself. JDBC provides the DatabaseMetaData interface for obtaining database-wide information and the ResultSetMetaData interface for obtaining information on the specific ResultSet .