Setting up a server to test Data source
In the Servers view, double-click the TitanServer server. The server editor opens.
Select the Data source tab at the bottom of the editor.
To test data sources at the node level, expand Node Settings. To test data sources at the server level, expand Server Settings.
Expand Server Settings.
A JDBC provider for DB2 and for Cloudscape will already be created for you (in the Server Settings section only). Before using the predefined JDBC provider, verify that the Class path field specified in the JDBC provider is the correct class path that contains the database driver. Select the JDBC provider from the JDBC provider list and click Edit to edit the JDBC class path.
Define a data source and resource properties. Beside Data sources defined in the JDBC provider selected above list, click Add.
Select the type of JDBC provider, for example Cloudscape JDBC Provider.
Select Version 5.0 data source and click Next.
On the Modify Data source page, specify the details of the data source that you want to create. For more information about any of the fields on this wizard, select the field and then press F1.
Name - TitanDS.
JNDI name - jdbc/TitanDS.
Select the Use this data source in container managed persistence (CMP) check box.
Click Next.
In the Resource Properties list table, select databaseName.
In the Value field, type the following: c:/titandb.
Click Finish. You associated a pooled database connection to a JNDI name that can be used by the application.
Adding Datasource references to enterprise bean
You can add different types of references to an enterprise bean, including resource references.
To add resource references to an enterprise bean:
In the J2EE Hierarchy view, right-click the desired EJB module and select Open With > Deployment Descriptor Editor from the pop-up menu.
On the References page of the editor select the enterprise bean that you want to add a reference to (the referencing bean) - Ship, and click the Add button. The Add Reference wizard opens.
Select the type of reference that you want to create (Resource reference), and click Next.
Complete these fields:
Name - Specifies the name of the reference (jdbc/TitanDS).
Type - The expected type of the resource manager connection factory (javax.sql.DataSource).
Authentication - Specifies the authentication method (container or application) for the resource manager (Container).
Sharing Scope - Specifies whether connections can be shareable or unshareable. This option is available for J2EE 1.3-compliant application client modules (Shareable).
Description - Text that describes the reference (Titan application Data Source).
Click Finish. 0
The reference is added to the bean that you selected and is displayed on the References page of the EJB deployment descriptor editor.
Add WebSphere Binding information (the JNDI (Java Naming and Directory Interface) name that the bean code uses to get a reference to a data source) - jdbc/TitanDS
The Data source reference is added to the ejb-jar.xml deployment descriptor:
<entity id="Ship"> <ejb-name>Ship</ejb-name> ... <resource-ref id="ResourceRef_1122305703058"> <description>Titan application Data Source</description> <res-ref-name>jdbc/TitanDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> </entity>
Defining JNDI bindings (CMP connection factory) 1
You can define JNDI bindings, or CMP connection factory bindings, for EJB 2.0 beans.
The CMP factory connection binding is a setting specific to WebSphere Application Server. See the WebSphere Application Server documentation for more detailed information about component-managed authentication and container-managed authentication.
To define CMP connection factory bindings: 2
Switch to the J2EE perspective.
In the J2EE Hierarchy view, right-click the desired EJB 2.0 module, and select Open With > Deployment Descriptor Editor from the pop-up menu.
On the Overview page of the editor, in the WebSphere Bindings section, go to the CMP Connection Factory Binding section. 3
Type a JNDI name - jdbc/TitanDS
Select one of the following container authentication types:
Per_Connection_Factory - Select this option for component-managed authentication. 4
Container - Select this option for container-managed authentication.