Define data sources for entity beans
Before an application that is installed on an appserver 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 appserver. Create a data source or JDBC resource and give it a Java Naming and Directory Interface (JNDI) name.
Overview
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
- Start the Application Server Toolkit.
- Optional: Open the J2EE perspective to work with J2EE projects. Click Window > Open Perspective > Other > J2EE.
- In the J2EE view, select the EJB module or individual EJB to open its deployment descriptor.
- Find the WebSphere bindings section.
- In the JNDI name field, enter the name of the data source or JDBC resource you want to use.
- Specify whether the authentication is handled at the container or application level.
- Save the deployment descriptor.
Application bindings
Related tasks
Binding EJB and resource references
Binding Web modules to virtual hosts