Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Storing Sessions in the Session Manager Instance

Although Oracle recommends that you export all session instances from TopLink Workbench to one or more `sessions.xml` files, alternatively, you can manually create a session in your application and, as Example 78-13 illustrates, manually store it in the session manager using `SessionManager` method `addSession`. Then, you can acquire a session by name using the `SessionManager` method `getSession`.

Note: The `addSession` method is not necessary if you are loading sessions from a session configuration file.

Example 78-13 Storing Sessions Manually in the Session Manager

    // create and log in to the session programmatically
    Session theSession = project.createDatabaseSession();
    theSession.login();
    // store the session in the SessionManager instance
    SessionManager manager = SessionManager.getManager();
    manager.addSession("mysession", theSession);
    // retrieve the session
    Session session = SessionManager.getManager().getSession("mysession");