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
 

Creating Database Sessions

Oracle recommends that you create database sessions using TopLink Workbench (see "Using TopLink Workbench").

After you create a database session, you can acquire and use it at run time. For more information on acquiring a database session, see "Acquiring a Session from the Session Manager".

Using TopLink Workbench

Before you create a database session, you must first create a sessions configuration (see "Creating a Sessions Configuration").

To create a new TopLink database session, use this procedure:

  1. Select the session configuration in the Navigator window in which you want to create a session.

  2. Add Session button.
    Click Add Session on the toolbar. The Create New Session dialog box appears.

    You can also create a new configuration by right-clicking the sessions configuration in the Navigator window and selecting New > Session from the context menu.

    Figure 76-5 Create New Session Dialog Box

    Create New Session dialog
  3. Complete each field on the Create New Session dialog box.

Use the following information to enter data in each field of the dialog box:

Field Description
Name Specify the name of the new session.
Use Server Platform Check this field if you intend to deploy your application to a J2EE application server.

If you check this field, you must configure the target application server by selecting a Platform.

Platform This option is available only if you check Use Server Platform.

Select the J2EE application server to which you will deploy your application.

TopLink supports the following J2EE application servers:

  • OC4J 10.1.3

  • OC4J 9.0.3Foot 1 

  • WebLogic 8.1

  • WebLogic 7.0

  • WebLogic 6.1

  • websphere 5.1

  • websphere 5.0

  • websphere 4.0

  • Custom

The server platform you select is the default server platform for all sessions you create in this sessions configuration. At the session level, you can override this selection or specify a custom server platform class (see "Configuring the Server Platform").

Select Data Source Select the data source for this session configuration. Each session configuration must contain one data source. Choose one of the following:
  • Database to create a session for a relational project.

  • EIS to create a session for an EIS project.

  • XML to create a session for an XML project.

See "TopLink Project Types" for more information.

Select Session Select Database Session to create a session for a single database (including shared object cache and connection pools) for a single client suitable for simple applications or prototyping.

Footnote 1 Includes support for both 9.0.3 and 9.0.4.

Enter the necessary information and click OK.

TopLink Workbench window appears, showing the database session in the Navigator window.

Continue with Chapter 77, "Configuring a Session".

Using Java

You can create an instance of the DatabaseSession class in Java code using a Project. You can create a project in Java code or read a project from a project.xml file.

Example 76-5 illustrates creating a DatabaseSession using a Project class.

Example 76-5 Creating a Database Session from a Project Class

Project myProject = new Project();
DatabaseSession databaseSession = myProject.createDatabaseSession();

Example 76-6 illustrates creating a DatabaseSession using a Project read in from a project.xml file.

Example 76-6 Creating a Database Session from a project.xml File Project

Project myProject = XMLProjectReader.read("myproject.xml");
DatabaseSession databaseSession = myProject.createDatabaseSession();