Define data sources for entity beans

 

Before you begin

Create a data source or JDBC resource and give it a Java Naming and Directory Interface (JNDI) name.

 

Overview

Before an application that is installed on an application server can start, all enterprise bean (EJB) references and resource references defined in the application must be bound to the actual artifacts (enterprise beans or resources) defined in the application server. For more information, see Application bindings.

The following steps assume that the entity beans in your application are container managed persistence (CMP) enterprise beans. The EJB container handles the persistence of the bean attributes in the underlying persistent store. You must specify which data store is used. You do this by binding an EJB module or individual EJB to a data source.

If you bind an EJB module to a data source, all beans in that module use the same data source for persistence. If you specify the data source at the bean level, then that data source is used instead.

 

Procedure

  1. Start the Application Server Toolkit.

  2. Optional: Open the J2EE perspective to work with J2EE projects. Click Window > Open Perspective > Other > J2EE.

  3. In the J2EE view, select the EJB module or individual EJB to open its deployment descriptor.

  4. Find the WebSphere bindings section.

  5. In the JNDI name field, enter the name of the data source or JDBC resource you want to use.

  6. Specify whether the authentication is handled at the container or application level.

  7. Save the deployment descriptor.


 

See Also


Application bindings

 

Related Tasks


Binding EJB and resource references
Binding Web modules to virtual hosts