Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
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".
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:
Select the session configuration in the Navigator window in which you want to create a session.
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.
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:
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:
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".
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.