Skip to Content

This web log explains you how to deploy a new custom data source in SAP NetWeaver  CE 7.1 to enable an application to get access to an external database other than the system databse of the SAP NW CE Application Server.

For an application to access an external database we have to deploy a data source for that database.But to deploy a datasource , we need to deploy  the relavant JDBC driver for that data base.

The process of enabling your application to get acces to an external database requires the following steps:

  • Deploying the Data Source
  • Deploying the Data Source Aliases

The known  ways to perform the above steps are:

    1. Throgh the  web based SAP Net Weaver Administrative tool.This is the easier way to deploy a new custom data source.
    2. Throuh the AS Java Telnet tool.This is a command line tool.You have to use DBPOOL shell command group to manage the data sources.
    3. As a part of the Java EE Application, using the SAP NW Dev Studio.

The rest of this blog will guide you to establish a connection with an external database(eg: MYSQL) using the Web based SAP NW Administrative tool. 

 SAP NW Administrative tool:

To start the SAP NetWeaver Administrator, enter the following URL in a Web browser: http://<host>:<port>/nwa, where:00.  For example, if the instance number of the Java instance is 60, the HTTP port is 56000.

     Select  Configuration Management >Infrastructure> Application Resources function

    *Procedure </p><p>1 Deploying a new JDBC driver:To create a Data Source, you must first deploy a  compatable JDBC driver.This has to be downloaded from the vendor’s web site.You can deploy either  JDBC 1.x or JDBC 2.0-compliant driver.When you first log on to the system there is already a defined driver. This is the system driver. You cannot remove this driver. </p><p>+Choose  Create New Resource->Deploy New JDBC Driver. +The new JDBC driver creation window opens.</p><ol><li>Enter an arbitrary name for the driver which will be used while creating the data source..</li><li>Choose ‘Add New driver File’.</li><li>Browse the driver file in the system.</li><li>Choose OK.</li></ol><p>!https://weblogs.sdn.sap.com/cs/blank/edit/wlg/|height=1|alt=|width=1|src=https://weblogs.sdn.sap.com/cs/blank/edit/wlg/|border=0!!../../../../weblogs/images/251842966/image2.JPG|height=197|alt=image|align=middle|width=396|src=../../../../weblogs/images/251842966/image2.JPG|border=0!</p><p> </p><p>On successfull deployment ,success message will be displayed..</p><p>2 Deploying a new Custom Data Source.* 

     Choose  Create New Resource->Deploy New JDBCCustom Data Source.The new JDBC Custom DataSource creation window opens.

     

    !../../../../weblogs/images/251842966/image5.JPG|height=368|alt=image|align=middle|width=518|src=../../../../weblogs/images/251842966/image5.JPG|border=0!

    Specify the name of the application that needs to be  associated to the JDBC DataSource in the Application Name field. The system uses this name for the configuration that holds the JDBC DataSource.

    Specify a unique name for the JDBC DataSource in the DataSource Name field. It is used when you look up the JDBC DataSource in the naming.

    Select a driver from the Driver Name dropdown list box. Choose the driver that you have created in the previous step.

    Select the SQL type support from the SQL Engine dropdown list box.

    In the context of the SAP NetWeaver Application Server Java, you can use Open SQL, Native SQL or Vendor SQL as the SQL engine types in your Data Source definition.

      1.  Vendor SQL can be used with any database that provides a JDBC-compliant     driver.
      2.  Native SQL is a wrapper for the vendor-specific JDBC driver and provides important enhancements such as SQL trace and statement pooling. However, it can be used only with databases supported by SAP: Oracle 9.2 and 10.2, MSSQL 8, MaxDB 7.x, and DB2 for Linux, UNIX, Windows, versions 9.x and 8.x.
      3. Open SQL is an SAP-proprietary database abstraction layer, which is designed to provide portability across various database platforms and performance optimizations through client-side data buffering.

    But ,if you want to connect your application to existing tables in an external database, then you should consider using a custom DataSource with Native SQL or Vendor SQL access type. Open SQL is not an option in this case, since it only works using the System DataSource and connecting to the system database schema.So choose Vendor SQL From the SQL Engine type drop down list.

    Select the transaction isolation level from the Isolation Level dropdown list box.

    Select the JDBC type support from the JDBC Version dropdown list box. Depending on the JDBC version you choose, you have to enter the following additional information:

      1. If you choose JDBC 1.x support, you have to enter a driver class name, database URL, user name, and password.
      2. If you choose JDBC 2.0 support, you have to enter the data source type, ConnectionPool DataSource or XA DataSource. You must also enter the class name for the corresponding implementation provided by the driver and the vendor-specific initialization properties (serverName, portNumber, and so on).

     

    You can define  Datasource alias(es)(eg:MYSQLDS_DS1_ALIAS1) for your datasource with JDBC Data Sources Aliases  tab.A Data Source alias is a logical name mapped to the name of a real Data Source available in the system. You use the Data Source alias in your application code to connect to the underlying Data Source.

    Finally,select  Save. The newly created DataSource appears in the list of JDBC Custom DataSources.

    Now you can use  your DataSource alias in your application code to connect to the underlying Data Source.

    ds = (DataSource) ctx.lookup(“jdbc/MYSQLDB_DS1_ALIAS1”);

    If you want you can view your data source aliases in the naming tree of the JNDI Registry using the JNDI Browser.

    To open JNDI Browser  Choose Problem Management–>JNDI Browser  in the NW Administrative tool.

    References:

    [SAP Help Documentation for deploying a Data Source | http://help.sap.com/saphelp_nwce10/helpdata/en/45/07d2eeea3e0485e10000000a155369/content.htm]

    [SAP Help Documentation for JNDI Browser | http://help.sap.com/saphelp_nwce10/helpdata/en/45/27b87fd3a96d95e10000000a114a6b/content.htm]

     

    To report this post you need to login first.

    5 Comments

    You must be Logged on to comment or reply to a post.

    1. Ritu Singh
      What will be the database URL if the Visual Administrator is on different machine and database is insatalled on different machine.
      And Do we have to make any changes if we are working in NWDS 7.0
      (0) 
      1. Sampath Gunda Post author
        DATABASE URL:
        jdbc:mysql://hostname:3306/databasename
        hostname:host name of the machine where you installed the DB SERVER
        EX:
        jdbc:mysql://dbserver:3306/compositeapplication_db
        (0) 
    2. Sumangala Byali
      Hi

      I am connecting to Mysql 5.0 from web dynpro java applicaiton.(NWDS 7.1)
      Which driver should be used?
      I tried with mysql-connector-java-5.0.8-bin.jar and mysql-connector-java-3.1.14-bin.jar.

      But when I create the datasource in NWA the status for datasource is green, but for driver the status is showing Unknown.Any idea as to what needs to be done.

      thanks and regrads,
      Sumangala

      (0) 

    Leave a Reply