Database Reference
In-Depth Information
the MySQL Connector/J driver there now if you haven't already (see
Recipe 18.3
).
After a restart, Tomcat will be able to use it.
3. Modify the Tomcat configuration file.
To tell Tomcat to use the
tomcat_session
table, modify the
mcb
application context
file. Change location into the
webapps/mcb/META-INF
under the Tomcat
we
bapps
directory, copy
context.xml.jdbc
to
context.xml
, and restart Tomcat.
If you look in
context.xml
, you'll find a
<Context>
element containing a
<Manag
er>
element that specifies the use of JDBC for MySQL-based session storage:
<Context
path=
"/mcb"
docBase=
"mcb"
debug=
"0"
reloadable=
"true"
>
<Manager
className=
"org.apache.catalina.session.PersistentManager"
debug=
"0"
saveOnRestart=
"true"
maxIdleBackup=
"600"
>
maxIdleSwap="1200"
minIdleSwap="900"
<Store
className=
"org.apache.catalina.session.JDBCStore"
driverName=
"com.mysql.jdbc.Driver"
connectionURL=
"jdbc:mysql://localhost/cookbook?user=cbuser&password=cbpass"
sessionTable=
"tomcat_session"
sessionIdCol=
"id"
sessionAppCol=
"app"
sessionDataCol=
"data"
sessionValidCol=
"valid_session"
sessionMaxInactiveCol=
"max_inactive"
sessionLastAccessedCol=
"update_time"
/>
</Manager>
</Context>
The
<Manager>
element attributes specify general session-related options. Within the
<Manager>
element body, the
<Store>
element provides attributes pertaining to the
JDBC driver. The following discussion focuses on the attributes shown in the example,
but there are others you can use. For more information, see the
Tomcat session-
The
<Manager>
attributes shown in the example have the following meanings:
className
The Java class that implements persistent session storage. It must be
org.apache.catalina.session.PersistentManager
.
debug
The logging detail level. A value of zero disables debug output; higher numbers
generate more output.