Show TOC

Procedure documentationCreating Database Connections Locate this document in the navigation structure

 

You use this procedure to define a connection profile and establish a connection to the database you are using for your application tables. You can:

  • Create a new database connection profile and use it when creating the development project for your entities (EJB, Dynamic Web, JPA).

  • Associate an existing database connection to an existing project that has the Java Persistence facet enabled.

    Note Note

    If you plan to use the system database, you have to define your tables in the Java Dictionary. Therefore, you must create a connection to the Java Dictionary.

    For more information, see Creating Connections to the Java Dictionary.

    End of the note.

Prerequisites

  • Your database server is up and running.

  • You have opened the Java EE perspective in the SAP NetWeaver Developer Studio.

Procedure

Creating New Database Connection Profiles
  1. In the Data Source Explorer, select Databases. In the context menu, choose New.

  2. In the New Connection Profile wizard, select a connection profile type according to the database vendor (for example, MaxDB), specify a Name for the new connection profile, then choose Next.

  3. Specify the driver and connection details as follows:

    1. Select a driver from the dropdown list.

      To define a new driver, choose New Driver Definition (New Driver Definition).

      In the New Driver Definition wizard, implement the following tasks:

      1. In the Name/Type tab, select a driver type and version. For example,   Database   MaxDB 7.7  .

      2. In the Jar List tab, select the driver file.

        To edit the selected driver location, choose Edit JAR/Zip.

        To specify a new location in the file system, choose Add JAR/Zip. For example, <MaxDB installation location>\programs\runtime\jar\sapdbc.jar.

      3. Choose OK.

    2. Complete the database connection details fields:

      1. Enter the Database name. For the system database, use the system ID (SID).

      2. If necessary, enter the connection URL. For example, jdbc:sapdb://<DB Host Name>/<Database>?timeout=0 for SAP Max DB database.

      3. If necessary, enter the Host name and the Port number of the database server.

      4. Enter the User name and Password to be used for connecting to the database. For the system database, you can use SAP<SID>DB as a user name.

        If you are using a custom database, you should use the same user name and password that you specify for connecting to the database in the definition of your custom DataSource object.

        For more information, see Deploying DataSources.

    3. (Optional) Choose Test Connection to ensure that you have specified the driver and the connection details properly.

    4. (Optional) To connect to the database immediately, select the Connect when the wizard completes checkbox.

  4. Choose Finish.

    The new database connection profile appears in the Databases tree of the Data Source Explorer.

  5. To establish a connection to the database, select the connection profile in the Data Source Explorer and choose Connect in the context menu.

Associating Existing Projects with Existing Database Connection Profiles
  1. Select the project in the Project Explorer.

  2. In the context menu, choose Properties.

  3. In the properties tree, choose JPA.

  4. Select the database connection profile from the Connection dropdown list.

  5. Choose Apply, then choose OK.