Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Step 2: Adding a Data Source

Each TopLink project requires a data source. For the tutorial project, you will use a relational database. In this tutorial, you will create a development login on the project to allow TopLink Workbench to access the database during development. Later, you will create a deployment login that your application will use when you deploy it to the application server (see "Creating a Database Deployment Login").

Creating a Database Development Login

To create a database login for TopLink Workbench to use during development, use this procedure:

  1. Expand the Employee project icon in the Navigator and select the Database icon. Its properties appear in the Editor.

    Verify that the Database Platform is correct. Click Change to select a different platform, if necessary.

  2. In the Defined Logins area, click Add. The Add New Login dialog box appears.

  3. Type the name for your login (for example, myLogin) and click OK. TopLink Workbench adds the newly created login to the Defined Logins area.

    Figure 17-6 Database Property Sheet

    Database property sheet
  4. Use the following information to complete the remaining login information:

    Field Description
    Driver Class Select the JDBC driver TopLink uses to communicate with your database (such as oracle.jdbc.OracleDriver).
    URL Specify the full location of your data source (such as jdbc:oracle:thin:@myserver:port:sid.
    Username Specify your username, required to log in to the database.
    Password Specify your password, required to log in to the database.
    Save Password Specify if TopLink if to save the password.

    When using JDK 1.4.1 (or later), the password is automatically encrypted with Java Cryptography Extension (JCE). For JDK versions prior to 1.4.1, refer to Oracle TopLink Getting Started Guide for information on using encrypted passwords.

    Development Login Select the login that you created (from the Defined Logins area).
    Deployment Login Ignore this field for now. You will specify a deployment login from the TopLink sessions configuration, later in this tutorial.

  5. New Project icon.
    Click Login on the tool bar to log in to the database.

    New Project icon.
    Notice that the database icon in the Navigator changes to let you know that you are currently logged in.

  6. Save button.
    Click Save to save the project.

Importing Database Tables

To import the database tables (including their attributes and constraints) into the TopLink Workbench project, use this procedure:

  1. Select the logged-in Database icon in the Navigator. Its properties appear in the Editor.

  2. New Project icon.
    Click Add or Update Existing Tables from Database. The Import Tables from Database dialog appears.

    Figure 17-7 numbered callouts identify the following groups of user interface elements on this dialog box:

    1. Filters: this area is made up of attributes Table Name Pattern, Catalog, Schema Pattern, and Table Type

    2. Available and selected items: the tables that match the filter attributes are listed in the left hand panel and the tables that you have selected are listed in the right hand panel.

    Figure 17-7 Import Tables from Database Dialog Box

    Import Tables from Database
    Description of "Figure 17-7 Import Tables from Database Dialog Box"

  3. Use the following information to complete the filter information in the Import Tables from Database dialog box:

    Field Description
    Table Name Pattern Use the percent symbol ( % ) as wildcard search to display all the database tables.
    Catalog The database creation scripts do not specify a catalog or schema. Consult your DBA for the correct information for your specific database and login.
    Schema Pattern
    Table Type Select TABLE as the database table type. TopLink also supports other database table types such as views and synonyms.

  4. Click Get Table Names. TopLink Workbench displays the database tables in the Available Tables area.

  5. Select the following tables (see "Data Model") and click Add Selected Items.

    • ADDRESS

    • EMPLOYEE

    • LPROJECT

    • PHONE

    • PROJ_EMP

    • PROJECT

    • RESPONS

    • SALARY

    • SEQUENCE

  6. Click OK. TopLink Workbench adds the tables to the project.

    Figure 17-8 TopLink Workbench

    OracleAS TopLink Mapping Workbench
  7. Save button.
    Click Save to save the project.

Project-Level Sequencing

Use this procedure to apply a sequence table to the project. The tutorial project uses custom sequencing for the Employee and Address classes. Later you will assign specific sequencing information for both classes.

  1. Select the Employee project in the Navigator. Its properties appear in the Editor.

  2. Click the Sequencing tab. The Sequencing tab appears.

    Figure 17-9 Sequencing Tab

    This illustration shows the Sequencing tab.
  3. Use the following information to complete each field on the Sequencing tab:

    Field Description
    Custom Sequence Table Specify that the project uses a custom sequence table.
        Name Select the SEQUENCE database table.
        Sequence Name Field Select the SEQ_NAME database field.
        Sequence Counter Field Select the SEQ_COUNT database field.

  4. Save button.
    Click Save to save the project.

Later, you will specify descriptor-level sequencing to track employees and their addresses.