Show TOC Start of Content Area

Procedure documentation Creating a DataSource Alias  Locate the document in its SAP Library structure

 

In order to enable communication with the database and to access the table from within the application, you must create a DataSource alias. This allows you to refer to the default DataSource from the J2EE Engine. The default DataSource is automatically created when you install the SAP J2EE Engine and it is not associated with a particular application which means that multiple applications can use a single DataSource.

The application only needs to know the name of the DataSource alias; the actual path to the database is stored in the DataSource definition in the server. The application can thus find all tables for the DataSource, including QCR_RESERVATION.

Prerequisites

This graphic is explained in the accompanying textThis graphic is explained in the accompanying text

Your application makes use of the default DataSource from the J2EE Engine.

This graphic is explained in the accompanying textThis graphic is explained in the accompanying text

You have entered CAR_RENTAL_POOL in the DataSource name field in the deployment descriptor persistent.xml of the QuickCarRentalEjb project (this step is described in Adding Descriptions to persistent.xml).

This graphic is explained in the accompanying text

The structure of your project QuickCarRentalEar is currently displayed in the J2EE Explorer.

Procedure

...

       1.      Choose the project node QuickCarRentalEar.

       2.      Open the context menu and choose New META-INF/data-source-aliases.xml.

       3.      In the wizard screen that appears, enter CAR_RENTAL_POOL in the Alias Name field.

       4.      Choose Finish.

The wizard adds a new XML file data-source-aliases.xml to the project structure.

 

This graphic is explained in the accompanying text

Result

You have added a DataSource alias with the name CAR_RENTAL_POOL to the project. The new alias is automatically assigned to the default DataSource. You now are able to check it by double-clicking the node This graphic is explained in the accompanying text META-INF/data-source-aliases.xml in the J2EE Explorer.

The XML editor then display the following code:

 

<?xml version="1.0"?>

<data-source-aliases>

   <aliases>

       <data-source-name>

           ${com.sap.datasource.default}

       </data-source-name>

       <alias> CAR_RENTAL_POOL </alias>

   </aliases>

</data-source-aliases>

 

Note:

In the generated XML, the name ${com.sap.datasource.default} represents the default DataSource stored in the server.

 

Next step:

Creating an Ear File

 

End of Content Area