Show TOC

Deploying DataSourcesLocate this document in the navigation structure

Use

There are two ways of deploying a DataSource:

  • As a standalone DataSource using the Telnet Administrator tool

  • As part of a Java EE 5 application using the SAP NetWeaver Developer Studio

Procedure

Deploying a Standalone DataSource

The standalone DataSource can be used by multiple applications. Its life cycle is independent from the life cycle of the applications that are using it.

To deploy a standalone DataSource, proceed as follows:

  1. Open the Telnet Administrator console:

    1. Go to the SAP Management Console and open the AS Java Process Table for your SAP NetWeaver Application Server for Java.

    2. Choose AS Java Telnet from the context menu of the ICM process.

  2. Log on to the server by providing a valid administrator user and password in the User name and Password fields in the Telnet Administrator console.

  3. Enter add dbpool in the command line to add the DBPOOL shell command group to the environment.

  4. Enter make_data_source <xml_descriptor> in the command line to deploy the DataSource defined by the <xml_descriptor> parameter.

    The <xml_descriptor> parameter specifies the path to your data-sources.xml file on the file system.

Deploying a Data Source within a Java EE 5 Application

If you deploy a DataSource as part of an application, the DataSource's life cycle will depend on the application's life cycle - that is, the DataSource is available only if the application that deployed it is started. It can also be used by other applications by declaring resource references to it in their deployment descriptors.

To deploy a DataSource with an application, you need to add a data-sources.xml to the META-INF folder of the application's EAR file. The following procedure describes how to do this using the SAP NetWeaver Developer Studio.

  1. Add the SAP Data Source facet to your EAR project.

    1. Select your EAR project in the Project Explorer , and choose Properties from the context menu.

    2. Select Project Facets from the properties tree

    3. Select the SAP Data Source checkbox.

    4. Choose Apply , then choose OK .

      The SAP NetWeaver Developer Studio creates the data-sources.xml file under the META-INF directory of your EAR project.

    5. To open the data-sources.xml file for editing, select the file and choose Open from the context menu.

  2. Using the Source or the Design view of the XML editor, fill out the elements you need to complete your DataSource definition.

    For more information about the available configuration elements, see data-sources.dtd .

Sample Code
                  <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE data-sources SYSTEM 'data-sources.dtd'>
<data-sources>
        <data-source>
                <data-source-name>SAPDB</data-source-name>
                <driver-name>SYSTEM_DRIVER</driver-name>
                <init-connections>1</init-connections>
                <max-connections>10</max-connections>
                <max-time-to-wait-connection>60</max-time-to-wait-connection>
                <expiration-control>
                        <connection-lifetime>600</connection-lifetime>
                        <run-cleanup-thread>60</run-cleanup-thread>
                </expiration-control>
                <sql-engine>native_sql</sql-engine>
                <jdbc-1.x>
                        <driver-class-name>com.sap.dbtech.jdbc.DriverSapDB</driver-class-name>
                        <url>jdbc:sapdb://localhost/JP1</url>
                        <user-name>sapdemo</user-name>
                        <password>sapdemo</password>
                </jdbc-1.x>
        </data-source>
</data-sources>