Modify the data source used by the EJB components

EJB components obtain database connections using JNDI. The EAServer component and package properties bind data source to the JNDI names used in the component implementation.

When we deployed the EJB-JAR file, EAServer bound the JNDI data source names to the default data source. We must reconfigure the properties to use the new data source that we just created.

StepsChanging the data source used by the EJB components

  1. In the Management Console, expand the EJB Modules folder and click on the ejbtut icon beneath it. The package configuration properties display.

  2. Display the Configuration tab. This tab displays the Ant configuration file that EAServer generated from the settings in the EJB-JAR deployment descriptor. Since this configuration file is regenerated if you redeploy the components, we will not modify it. Instead we will create a user-configuration file.

  3. Right-click the ejbtut icon beneath the EJB Modules folder and choose Create User Configuration. You see a dialog saying the User Configuration File is created. Right-click the ejbtut icon again and choose Refresh to display the User Configuration tab.

  4. Click the User Configuration Tab to display the file contents. The configuration information is the XML text of an Ant build file that sets the package and component properties.

    Add the following line above the import elements to define the data source name that the components connect to:

    <property name="sql.dataSource" value="Glossary"/>
    

    Find the definition of the configure-user target, and add the statements below inside the start and end tags for the target. The target definition in your file should look like this:

    <target name="configure-user">
      <echo level="info" message="configure: ejbjar-ejbtut-user"/>
      <echo level="info" message="sql.dataSource is ${sql.dataSource}"/>
    </target>
    

    Click Apply at the bottom of the page to save the changes.

  5. Right-click on the ejbtut icon beneath the EJB Modules folder and choose Run Ant Recompile. The Management Console runs the Recompile task defined in the configuration file, applying the changes to the package and component properties and regenerating the runtime classes required to integrate the components into EAServer.

    Review the output that displays in the right pane. You see Build Successful at the bottom of the output if everything goes ok.