IN THIS CHAPTER
Java database connectivity
The Hibernate framework
Java has a wide variety of libraries available for working with databases. This chapter discusses two of the most widely used methods of working with databases in Java. The first, Java Database Connectivity, is included with the Java Development Kit. The second, Hibernate, is a separate open-source library.
Java Database Connectivity (JDBC) has been a standard component of the JDK almost since the beginning. JDK version 6 includes JDBC 4.0. It provides a set of classes that allow you to execute SQL statements and queries against a database and then work with the results. Because it uses standard SQL, developers who are familiar with SQL and running queries against a database are able to pick it up fairly quickly.
For more on databases and SQL, see Chapter 8.
The JDBC classes included with the JDK are part of the
javax.sql packages. There are a number of classes and interfaces in this package. These include the following:
Connection interface represents a connection to a database.
Connection is used to create the statements and queries that are run against the database as well as to retrieve information about the database itself.
Statement interface represents the SQL statement to be run against the database.
PreparedStatement interface is much like the
Statement interface, but it also allows the addition of parameters. This ...