Why and when to perform this task
Note: WebSphere Application Server does not support JDBC 3.0.
You can access data in various ways:
Steps for this task
The Enterprise JavaBeans (EJB) programming model provides several distinct server-side component types: entity, session, and message-driven beans, and servlets. Of these types, entity beans are typically used to model business components in an application. Entity beans have both state and behavior.
The state of entity beans is persistent and is stored in a database. As changes are made to an entity bean, its state is kept in synchronization with the database record representing the bean. There are two types of entity beans provided by the EJB model and these two types differ in the mechanism used to provide persistence. These two types of entity beans are container-managed persistence (CMP) beans and bean-managed persistence (BMP) beans.
With BMP beans, the developer manually produces code to manage the persistent state of the bean.
With CMP beans, the EJB container manages the beans persistent state. Persistent state management is a complex and difficult task and using CMP beans allows the developer to concentrate on business logic by delegating persistence behavior to the container. Typical examples of CMP beans are Customer, Account, and so on. Because CMP beans are objects, their data (state) is accessed using field accessors. For example, a Customer entity bean is likely to have fields such as name and phoneNumber. These pieces of data are accessed using the accessor methods getName()/setName() and getPhoneNumber()/setPhoneNumber(). As a developer, you are not concerned with how this data is eventually stored and retrieved from the backend database and can assume that the integrity of the data is maintained by the container.
Starting
with WebSphere Application Server Version 5.0.1, you can use Structured Query
Language in Java (SQLJ) support with both BMP and CMP beans when you are using
the DB2 Universal JDBC driver provider with DB2 as your backend database.
You can also use SQLJ support with BMP beans when you are using the DB2 for
z/OS Local JDBC provider (RRS) with DB2 for z/OS as your backend database.
DB2 for z/OS users who wish to use SQLJ support with CMP beans must use the
DB2 Universal JDBC driver provider.