org.apache.catalina.session
public class JDBCStore extends StoreBase implements Store
Store
interface that stores
serialized session objects in a database. Sessions that are
saved are still subject to being expired based on inactivity.
Version: $Revision: 554109 $, $Date: 2007-07-07 03:40:19 +0200 (Sat, 07 Jul 2007) $
Field Summary | |
---|---|
protected String | connectionName
The connection username to use when trying to connect to the database. |
protected String | connectionPassword
The connection URL to use when trying to connect to the database. |
protected String | connectionURL
Connection string to use when connecting to the DB. |
protected Driver | driver
Instance of the JDBC Driver class we use as a connection factory. |
protected String | driverName
Driver to use. |
protected static String | info
The descriptive information about this implementation. |
protected PreparedStatement | preparedClearSql
Variable to hold the clear() prepared statement. |
protected PreparedStatement | preparedKeysSql
Variable to hold the keys() prepared statement. |
protected PreparedStatement | preparedLoadSql
Variable to hold the load() prepared statement. |
protected PreparedStatement | preparedRemoveSql
Variable to hold the remove() prepared statement. |
protected PreparedStatement | preparedSaveSql
Variable to hold the save() prepared statement. |
protected PreparedStatement | preparedSizeSql
Variable to hold the getSize() prepared statement. |
protected String | sessionAppCol
Column to use for /Engine/Host/Context name |
protected String | sessionDataCol
Data column to use. |
protected String | sessionIdCol
Id column to use. |
protected String | sessionLastAccessedCol
Last Accessed column to use. |
protected String | sessionMaxInactiveCol
Max Inactive column to use. |
protected String | sessionTable
Table to use. |
protected String | sessionValidCol
Is Valid column to use. |
protected static String | storeName
Name to register for this Store, used for logging. |
protected String | threadName
Name to register for the background thread. |
Method Summary | |
---|---|
void | clear()
Remove all of the Sessions in this Store.
|
protected void | close(Connection dbConnection)
Close the specified database connection.
|
protected Connection | getConnection()
Check the connection associated with this store, if it's
null or closed try to reopen it.
|
String | getConnectionName()
Return the username to use to connect to the database.
|
String | getConnectionPassword()
Return the password to use to connect to the database.
|
String | getConnectionURL()
Return the Connection URL for this Store. |
String | getDriverName()
Return the driver for this Store. |
String | getInfo()
Return the info for this Store. |
String | getName()
Return the name for this instance (built from container name) |
String | getSessionAppCol()
Return the web application name column for the table. |
String | getSessionDataCol()
Return the data column for the table |
String | getSessionIdCol()
Return the Id column for the table. |
String | getSessionLastAccessedCol()
Return the Last Accessed column |
String | getSessionMaxInactiveCol()
Return the Max Inactive column |
String | getSessionTable()
Return the table for this Store. |
String | getSessionValidCol()
Return the Is Valid column |
int | getSize()
Return an integer containing a count of all Sessions
currently saved in this Store. |
String | getStoreName()
Return the name for this Store, used for logging. |
String | getThreadName()
Return the thread name for this Store. |
String[] | keys()
Return an array containing the session identifiers of all Sessions
currently saved in this Store. |
Session | load(String id)
Load the Session associated with the id id .
|
protected Connection | open()
Open (if necessary) and return a database connection for use by
this Realm.
|
protected void | release(Connection conn)
Release the connection, not needed here since the
connection is not associated with a connection pool.
|
void | remove(String id)
Remove the Session with the specified session identifier from
this Store, if present. |
void | save(Session session)
Save a session to the Store.
|
void | setConnectionName(String connectionName)
Set the username to use to connect to the database.
|
void | setConnectionPassword(String connectionPassword)
Set the password to use to connect to the database.
|
void | setConnectionURL(String connectionURL)
Set the Connection URL for this Store.
|
void | setDriverName(String driverName)
Set the driver for this Store.
|
void | setSessionAppCol(String sessionAppCol)
Set the App column for the table.
|
void | setSessionDataCol(String sessionDataCol)
Set the Data column for the table
|
void | setSessionIdCol(String sessionIdCol)
Set the Id column for the table.
|
void | setSessionLastAccessedCol(String sessionLastAccessedCol)
Set the Last Accessed column for the table
|
void | setSessionMaxInactiveCol(String sessionMaxInactiveCol)
Set the Max Inactive column for the table
|
void | setSessionTable(String sessionTable)
Set the table for this Store.
|
void | setSessionValidCol(String sessionValidCol)
Set the Is Valid column for the table
|
void | start()
Called once when this Store is first started. |
void | stop()
Gracefully terminate everything associated with our db.
|
clear()
prepared statement.keys()
prepared statement.load()
prepared statement.remove()
prepared statement.save()
prepared statement.getSize()
prepared statement.Throws: IOException if an input/output error occurs
Parameters: dbConnection The connection to be closed
null
or closed try to reopen it.
Returns null
if the connection could not be established.
Returns: Connection
if the connection suceeded
0
is returned.
Throws: IOException if an input/output error occurred
Throws: IOException if an input/output error occurred
id
.
If no such session is found null
is returned.
Parameters: id a value of type String
Returns: the stored Session
Throws: ClassNotFoundException if an error occurs IOException if an input/output error occurred
Throws: SQLException if a database error occurs
Parameters: conn The connection to be released
Parameters: id Session identifier of the Session to be removed
Throws: IOException if an input/output error occurs
Parameters: session the session to be stored
Throws: IOException if an input/output error occurs
Parameters: connectionName Username
Parameters: connectionPassword User password
Parameters: connectionURL The new Connection URL
Parameters: driverName The new driver
Parameters: sessionAppCol the column name
Parameters: sessionDataCol the column name
Parameters: sessionIdCol the column name
Parameters: sessionLastAccessedCol The column name
Parameters: sessionMaxInactiveCol The column name
Parameters: sessionTable The new table
Parameters: sessionValidCol The column name