Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
Oracle recommends that you create server sessions using TopLink Workbench (see "Using TopLink Workbench").
After you create a server session, you create a client session by acquiring it from the server session (see "Acquiring a Client Session").
Before you create a server session, you must first create a sessions configuration (see "Creating a Sessions Configuration").
Creating a Session
To create a new TopLink server session, use this procedure:
Select the sessions 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 server session by right-clicking the sessions configuration in the Navigator and selecting New > Session from the context menu, or by clicking Add Session on the Sessions Configuration property sheet.
Figure 76-3 Create New Session Dialog Box
Enter data in 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 only available 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 Server Session to create a session for a single data source (including shared object cache and connection pools) for multiple clients in a three-tier application. |
Footnote 1 You cannot create a server session for an XML project.
You can create a server session 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-1 illustrates creating an instance (called serverSession
) of a Server
class using a Project
class.
Example 76-1 Creating a Server Session from a Project Class
Project myProject = new Project(); Server serverSession = myProject.createServerSession();
Example 76-2 illustrates creating an instance (called serverSession
) of a Server
class using a Project
read in from a project.xml
file.
Example 76-2 Creating a Server Session from a project.xml File Project
Project myProject = XMLProjectReader.read("myproject.xml"); Server serverSession = myProject.createServerSession();
Example 76-3 illustrates creating a server session with a specified write connection pool minimum and maximum size (when using TopLink internal connection pooling). The default write connection pool minimum size is 5 and maximum size is 10.