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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.