Chapter 9: Practical Data Access

Overview

In this chapter, we survey some leading data-access technologies and choose one for use in our sample application.

The data access technologies discussed in this chapter can be used anywhere in a J2EE application. Unlike entity beans, they are not tied to use in an EJB container. This has significant advantages for testing and architectural flexibility. However, we may still make good use of session EJB CMT, when we implement data access within the EJB container.

This chapter focuses on accessing relational databases, as we've previously noted that most J2EE applications work with them.

We consider SQL-based technologies and O/R mapping technologies other than entity beans. We will see the potential importance of Java Data Objects, a new API for persisting Java objects, which may standardize the use of O/R mapping in Java.

We focus on JDBC which best fulfils the data access requirements of the sample application.

We look at the JDBC API in detail, showing how to avoid common JDBC errors and discussing some subtle points that are often neglected.

As the JDBC API is relatively low-level, and using it is error-prone and requires an unacceptable volume of code, it's important for application code to work with higher-level APIs built on it. We'll look at the design, implementation, and usage of a JDBC abstraction framework that greatly simplifies the use of JDBC. This framework is used in the sample application, and can be used in any application using JDBC.

As we discussed in Chapter 7, it's desirable to separate data access from business logic. We can achieve this separation by concealing the details of data access behind an abstraction layer such as an O/R mapping framework or the Data-Access Objects (DAO) pattern.

We conclude by looking at the DAO pattern in action, as we implement some of the core data-access code of the sample application using the DAO pattern and the JDBC abstraction framework discussed in this chapter.



Expert One-on-One J2EE Design and Development
Microsoft Office PowerPoint 2007 On Demand
ISBN: B0085SG5O4
EAN: 2147483647
Year: 2005
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net