O'Reilly logo

Java® and Flex® Integration Bible by Charles A. Christiansen, Matthew Keefe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Java and Databases

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

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.

Note

For more on databases and SQL, see Chapter 8.

Overview of JDBC

The JDBC classes included with the JDK are part of the java.sql and javax.sql packages. There are a number of classes and interfaces in this package. These include the following:

  • The 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.

  • The Statement interface represents the SQL statement to be run against the database.

  • The PreparedStatement interface is much like the Statement interface, but it also allows the addition of parameters. This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required