Developing data access applications

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

  1. Decide how to implement data access.

    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.

    [Version 5.0.1 and later]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.

  2. Create a JDBC provider and data source (Creating and configuring a JDBC provider and data source ).
    A data source is associated with a JDBC provider that supplies the specific JDBC driver implementation class. The data source represents a connection factory for the relational resource adapter.
  3. Look up a data source or connection factory using a resource reference (Looking up data sources with resource references for relational access).
    Using a resource reference to access your data source or connection factory is required when running in WebSphere Application Server.
  4. Get a connection to a data source (Connection management architecture).
    The connection management architecture for both relational and procedural access to enterprise information systems (EIS) is based on the J2EE Connector Architecture (JCA) specification. The Connection Manager (CM), which pools and manages connections within an application server, is capable of managing connections obtained through both resource adapters (RAs) defined by the JCA specification, and DataSources defined by the JDBC 2.0 Extensions Specification.

Related concepts
Looking up data sources with resource references for relational access
Exceptions pertaining to data access
Embedded Structured Query language in Java (SQLJ) support[Version 5.0.1 and later]



Searchable topic ID:   impdatacc
Last updated: Jun 21, 2007 4:12:58 PM CDT    WebSphere Application Server Express, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.exp.doc/info/exp/ae/tdat_impdatacc.html

Library | Support | Terms of Use | Feedback