4.5. Data Access Object Pattern

The Music EJB shown in this chapter accesses a database using the JDBC's SQL interface. It works fine with Cloudscape's reference implementation of SQL (provided by Sun's J2EE reference implementation) but what happens if we change databases? How would this affect our code? Unfortunately, porting the current version of the Music EJB to a different database is not as smooth as one would like. Specifically, changes may be necessary to the bean implementation class, MusicBean.java. Although we isolated database access to separate private methods in the Music EJB, the EJB code must still be recompiled and redeployed.

The Data Access Object (DAO) pattern introduces a deeper level of abstraction for any EJB that accesses ...

Get Enterprise JavaBeans™ Component Architecture: Designing and Coding Enterprise Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.