+

Search Tips   |   Advanced Search

Configure database session persistence

We can use scripting and wsadmin.sh to configure database persistence.

Before starting this task, wsadmin.sh must be running. See the Start the wsadmin scripting client topic for more information.

To configure database persistence. Within these steps, the following variables apply to the Jython and Jacl commands:

  1. Retrieve the configuration ID of the server to enable database persistence and store its values in the server variable.

    • Jacl:

        set server [$AdminConfig getid /Node:node/Server:server_name/]

      Example output:

      server_name(cells/cell_name/nodes/node/servers/server_name
      |server.xml#Server_1265038035855)

    • Jython:

        server = AdminConfig.getid('/Node:node/Server:server_name/')

      Example output: None

  2. Retrieve the name of the session manager, which is associated with the server values in the previous step, and assign the session manager to the sm variable.

    • Jacl:

        set sm [$AdminConfig list SessionManager $server]

      Example output:

      (cells/cell_name/nodes/node/servers/server_name
      |server.xml#SessionManager_1256932276179)

    • Jython:

        sm = AdminConfig.list('SessionManager', server)

      Example output: None

  3. Add the database session persistence mode value to the sm variable, which already contains the session manager value from the previous steps.

    • Jacl:

        $AdminConfig modify $sm {{sessionPersistenceMode "DATABASE"}}

      Example output: None

    • Jython:

        AdminConfig.modify(sm,'[[sessionPersistenceMode "DATABASE"]]')

      Example output: None

  4. Retrieve the database session persistence value for the session manager and the database session persistence mode that are set to the sm variable. Set to the sesdb variable.

    • Jacl:

        set sesdb [$AdminConfig list SessionDatabasePersistence $sm]

      Example output:

      (cells/cell_name/nodes/node/servers/server_name
      |server.xml#SessionDatabasePersistence_1256932276179)

    • Jython:

        sesdb = AdminConfig.list('SessionDatabasePersistence',sm)

      Example output: None

  5. Modify the sesdb variable to include the user ID and password to access the database and the table space name; and the Java naming and directory interface (JNDI) name.

    • Jacl:

      $AdminConfig modify $sesdb { {userId "db2_administrator"} {password "db2_password"}
       {tableSpaceName ""} {datasourceJNDIName "jdbc/SessionDataSource"} }

      Example output: None

    • Jython:

        AdminConfig.modify(sesdb,'[[userId "db2_administrator"] [password "db2_password"] [tableSpaceName ""] [datasourceJNDIName "jdbc/SessionDataSource"]]')

      Example output: None

  6. Save the configuration changes. For more information, see the documentation on saving configuration changes with wsadmin.sh.


Related tasks

  • Saving configuration changes with wsadmin.sh
  • Use the wsadmin scripting AdminConfig object for scripted administration

  • Commands for the AdminConfig object
  • Configure for database session persistence