セッション永続化のためにJDBCStoreを使用 Home

Using JDBCStore for Session persistence

セッション永続化のためにJDBCStoreを使用

What is JDBCStore?

JDBCStore とは?

Is an implementation of a tomcat 4.X Store that use a table to store sessions. When to store sessions is configured in the Manager, currently the only Manager supported is the PersistentManager. Please consult the Manager manual for configuring the PersistentManager.

JDBCStoreとは、セッションを格納するためにテーブルを使うtomcat 4.Xストアの実装です。 セッションを格納するためにマネージャーにおいて構成されるとき、サポートされる現在ただひとつのマネージャーはPersistentManagerです。 PersistentManagerを構成するために、マネージャー・マニュアルを参照してください。
All the parameters, drivers, tables, and columns are user configurable.

全てのパラメータ、ドライバ、テーブル、カラム、ユーザは、可変です。

Example Config for JDBCStore

JDBCStoreの設定例

This is an example of how to set up a JDBCStore. For this example I used the MySQL JDBC driver. これは、JDBCStoreをどのように設定するかの例です。この例では、MySQL JDBCドライバを使用しました。

1. Create a database.

1. データベースを作成

I made the database named "tomcat"

「tomcat」という名前のデータベースを作成しました

2. Create the needed table.

2. 必要なテーブルを作成

1. The session table.

1. session テーブル

This table holds the sessions currently stored due to backup/swapout/maxidle or other criteria met.

このテーブルは、現在のセッションをテーブルに保持して、 backup/swapout/maxidle,その他criteria met.

create database tomcat;

create table tomcat$sessions
(
    id varchar(100) not null primary key,
    valid char(1) not null,
    maxinactive int not null,
    lastaccess bigint,
    data mediumblob
);


Here is sample output from the tables:
これは、テーブルからの出力例です。

mysql> create database tomcat;
Query OK, 1 row affected (0.02 sec)

mysql> use tomcat;
Database changed

mysql> create table tomcat$sessions
    -> (
    -> id varchar(100) not null primary key,
    -> valid char(1) not null,
    -> maxinactive int not null,
    -> lastaccess bigint,
    -> data mediumblob);
Query OK, 0 rows affected (0.01 sec)

3. Configure Tomcat

3. Tomcatの設定

Add the information to the server.xml file. Make sure that you configure the Store inside a Manger. PersistentManager is the only one supported as of writing. For this example I used this entry inside:

情報をserver.xmlファイルに加えてください。 あなたがマネージャーの中にストアを構成することを確認してください。 PersistentManagerは、現在書くことサポートする唯一のものです。 この例のために、私はこのエントリを中で使いました:


<Manager className="org.apache.catalina.session.PersistentManager" debug="0" saveOnRestart="true" maxActiveSessions="-1" minIdleSwap="-1" maxIdleSwap="-1" maxIdleBackup="-1">
<Store className="org.apache.catalina.session.JDBCStore"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/tomcat?user=test&amp;password=test"
sessionTable="tomcat$sessions"
sessionIdCol="id"
sessionDataCol="data"
sessionValidCol="valid"
sessionMaxInactiveCol="maxinactive"
sessionLastAccessedCol="lastaccess"
checkInterval="60"
debug="99" />
<Manager>

The meaning of the attributes is as follow:

属性の意味は以下のとおりです

attribute属性

Meaning意味
className The class to use as a Store, If you want to use a different Store than JDBCStore you're reading the wrong file
driverName The name of the driver needed to connect to the database
connectionURL The connection URL used to connect to the database
sessionTable The table in which we store our sessions
sessionIdCol The column in the session table that contains the session ID
sessionDataCol The column in the session table that contains the session data
sessionValidCol The column in the session table that holds if the session is valid or not.
sessionMaxInactiveCol The column in the session table that contains the sessions Max Inactive property
sessionLastAccessedCol The column in the session table that contains the last accesed time
checkInterval The time in seconds for the processExpires thread to sleep, a lower value causes more accurate expiring and removing old sessions from the RDBMS but could cause a heavily loaded site to go on it's knees if set to low.
debug The debug level for this Store, 0 means don't log any debug information and that's probably what you would want for a production enviroment.

 

$Header: /home/cvs/jakarta-tomcat-4.0/catalina/docs/JDBCStore-howto.html,v 1.1 2001/04/27 22:11:03 bip Exp $