Professional Java.JDK.5.Edition (Wrox)
.pdfPersisting Your Application
Using Databases
In the last chapter, you learned about how to persist the state of your application using file-based mechanisms. This is a useful way to handle things in a single-user model, but when multiple users need to share the same data, databases are the solution. Now, you will learn about how to persist your application to a database.
Persisting your data to a database has always required true effort, regardless of your development language. Java has been making substantial leaps in this area and has come a long way in making the task much easier with their addition of the JDBC 3.0 API. Java also has an ever-growing open source community that is releasing new and improved technologies every year.
This chapter will discuss how to persist your application’s data to a database using features of the JDBC 3.0 API, such as RowSets and Distributed Transactions. It will also allow you to take an indepth look at Hibernate, a powerful object/relational mapping tool that is used to store and retrieve Java objects to and from relational databases.
Java and its open source community are becoming extremely aware of the importance of data persistence, especially for a developer in a J2EE architecture. Therefore they continue to enhance the JDBC API to support the ever-growing needs of its developers.
JDBC API Over view
The JDBC API provides a simple way for Java applications to access data from one or more relational data sources. A Java developer can use the JDBC API to do the following things:
Connect to a data source
Execute complex SQL statements