Package org.apache.catalina.session

## Class JDBCStore

- java.lang.Object
- - org.apache.catalina.util.LifecycleBase
  - - org.apache.catalina.session.StoreBase
    - - org.apache.catalina.session.JDBCStore

All Implemented Interfaces:
  `Lifecycle`, `Store`

Direct Known Subclasses:
  `DataSourceStore`

    @Deprecated
    public class JDBCStore
    extends StoreBase

Deprecated.
Removed in Tomcat 10 and replaced by DataSourceStore with removal of legacy JDBC code
Implementation of the `Store` interface that stores serialized session objects in a database. Sessions that are saved are still subject to being expired based on inactivity.

Author:
  Bip Thelin

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

`Lifecycle.SingleUse`

### Field Summary

Fields
`protected java.lang.String` `connectionName` Deprecated. The connection username to use when trying to connect to the database.
`protected java.lang.String` `connectionPassword` Deprecated. The connection URL to use when trying to connect to the database.
`protected java.lang.String` `connectionURL` Deprecated. Connection string to use when connecting to the DB.
`protected javax.sql.DataSource` `dataSource` Deprecated. DataSource to use
`protected java.lang.String` `dataSourceName` Deprecated. name of the JNDI resource
`protected java.sql.Driver` `driver` Deprecated. Instance of the JDBC Driver class we use as a connection factory.
`protected java.lang.String` `driverName` Deprecated. Driver to use.
`protected java.sql.PreparedStatement` `preparedClearSql` Deprecated. Variable to hold the `clear()` prepared statement.
`protected java.sql.PreparedStatement` `preparedLoadSql` Deprecated. Variable to hold the `load()` prepared statement.
`protected java.sql.PreparedStatement` `preparedRemoveSql` Deprecated. Variable to hold the `remove()` prepared statement.
`protected java.sql.PreparedStatement` `preparedSaveSql` Deprecated. Variable to hold the `save()` prepared statement.
`protected java.sql.PreparedStatement` `preparedSizeSql` Deprecated. Variable to hold the `getSize()` prepared statement.
`protected java.lang.String` `sessionAppCol` Deprecated. Column to use for /Engine/Host/Context name
`protected java.lang.String` `sessionDataCol` Deprecated. Data column to use.
`protected java.lang.String` `sessionIdCol` Deprecated. Id column to use.
`protected java.lang.String` `sessionLastAccessedCol` Deprecated. Last Accessed column to use.
`protected java.lang.String` `sessionMaxInactiveCol` Deprecated. Max Inactive column to use.
`protected java.lang.String` `sessionTable` Deprecated. Table to use.
`protected java.lang.String` `sessionValidCol` Deprecated. `Is Valid` column to use.
`protected static java.lang.String` `storeName` Deprecated. Name to register for this Store, used for logging.
`protected static java.lang.String` `threadName` Deprecated. Name to register for the background thread.

### Fields inherited from class org.apache.catalina.session.StoreBase

`manager, sm, support`

### Fields inherited from interface org.apache.catalina.Lifecycle

`AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

### Constructor Summary

Constructors
`JDBCStore()` Deprecated.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`void` `clear()` Deprecated. Remove all of the Sessions in this Store.
`protected void` `close​(java.sql.Connection dbConnection)` Deprecated. Close the specified database connection.
`java.lang.String[]` `expiredKeys()` Deprecated. Get only those keys of sessions, that are saved in the Store and are to be expired.
`protected java.sql.Connection` `getConnection()` Deprecated. Check the connection associated with this store, if it's `null` or closed try to reopen it.
`java.lang.String` `getConnectionName()` Deprecated.
`java.lang.String` `getConnectionPassword()` Deprecated.
`java.lang.String` `getConnectionURL()` Deprecated.
`java.lang.String` `getDataSourceName()` Deprecated.
`java.lang.String` `getDriverName()` Deprecated.
`boolean` `getLocalDataSource()` Deprecated.
`java.lang.String` `getName()` Deprecated.
`java.lang.String` `getSessionAppCol()` Deprecated.
`java.lang.String` `getSessionDataCol()` Deprecated.
`java.lang.String` `getSessionIdCol()` Deprecated.
`java.lang.String` `getSessionLastAccessedCol()` Deprecated.
`java.lang.String` `getSessionMaxInactiveCol()` Deprecated.
`java.lang.String` `getSessionTable()` Deprecated.
`java.lang.String` `getSessionValidCol()` Deprecated.
`int` `getSize()` Deprecated. Return an integer containing a count of all Sessions currently saved in this Store.
`java.lang.String` `getStoreName()` Deprecated.
`java.lang.String` `getThreadName()` Deprecated.
`java.lang.String[]` `keys()` Deprecated.
`Session` `load​(java.lang.String id)` Deprecated. Load the Session associated with the id `id`.
`protected java.sql.Connection` `open()` Deprecated. Open (if necessary) and return a database connection for use by this Store.
`protected void` `release​(java.sql.Connection conn)` Deprecated. Release the connection, if it is associated with a connection pool.
`void` `remove​(java.lang.String id)` Deprecated. Remove the Session with the specified session identifier from this Store, if present.
`void` `save​(Session session)` Deprecated. Save a session to the Store.
`void` `setConnectionName​(java.lang.String connectionName)` Deprecated. Set the username to use to connect to the database.
`void` `setConnectionPassword​(java.lang.String connectionPassword)` Deprecated. Set the password to use to connect to the database.
`void` `setConnectionURL​(java.lang.String connectionURL)` Deprecated. Set the Connection URL for this Store.
`void` `setDataSourceName​(java.lang.String dataSourceName)` Deprecated. Set the JNDI name of a DataSource-factory to use for db access
`void` `setDriverName​(java.lang.String driverName)` Deprecated. Set the driver for this Store.
`void` `setLocalDataSource​(boolean localDataSource)` Deprecated. Set to `true` to cause the datasource to be looked up in the webapp JNDI Context.
`void` `setSessionAppCol​(java.lang.String sessionAppCol)` Deprecated. Set the App column for the table.
`void` `setSessionDataCol​(java.lang.String sessionDataCol)` Deprecated. Set the Data column for the table
`void` `setSessionIdCol​(java.lang.String sessionIdCol)` Deprecated. Set the Id column for the table.
`void` `setSessionLastAccessedCol​(java.lang.String sessionLastAccessedCol)` Deprecated. Set the `Last Accessed` column for the table
`void` `setSessionMaxInactiveCol​(java.lang.String sessionMaxInactiveCol)` Deprecated. Set the `Max Inactive` column for the table
`void` `setSessionTable​(java.lang.String sessionTable)` Deprecated. Set the table for this Store.
`void` `setSessionValidCol​(java.lang.String sessionValidCol)` Deprecated. Set the `Is Valid` column for the table
`protected void` `startInternal()` Deprecated. Start this component and implement the requirements of `LifecycleBase.startInternal()`.
`protected void` `stopInternal()` Deprecated. Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.

### Methods inherited from class org.apache.catalina.session.StoreBase

`addPropertyChangeListener, destroyInternal, getManager, getObjectInputStream, initInternal, processExpires, removePropertyChangeListener, setManager, toString`

### Methods inherited from class org.apache.catalina.util.LifecycleBase

`addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### storeName

    protected static final java.lang.String storeName

Deprecated.
Name to register for this Store, used for logging.

See Also:
  Constant Field Values

#### threadName

    protected static final java.lang.String threadName

Deprecated.
Name to register for the background thread.

See Also:
  Constant Field Values

#### connectionName

    protected java.lang.String connectionName

Deprecated.
The connection username to use when trying to connect to the database.

#### connectionPassword

    protected java.lang.String connectionPassword

Deprecated.
The connection URL to use when trying to connect to the database.

#### connectionURL

    protected java.lang.String connectionURL

Deprecated.
Connection string to use when connecting to the DB.

#### driver

    protected java.sql.Driver driver

Deprecated.
Instance of the JDBC Driver class we use as a connection factory.

#### driverName

    protected java.lang.String driverName

Deprecated.
Driver to use.

#### dataSourceName

    protected java.lang.String dataSourceName

Deprecated.
name of the JNDI resource

#### dataSource

    protected javax.sql.DataSource dataSource

Deprecated.
DataSource to use

#### sessionTable

    protected java.lang.String sessionTable

Deprecated.
Table to use.

#### sessionAppCol

    protected java.lang.String sessionAppCol

Deprecated.
Column to use for /Engine/Host/Context name

#### sessionIdCol

    protected java.lang.String sessionIdCol

Deprecated.
Id column to use.

#### sessionDataCol

    protected java.lang.String sessionDataCol

Deprecated.
Data column to use.

#### sessionValidCol

    protected java.lang.String sessionValidCol

Deprecated.
`Is Valid` column to use.

#### sessionMaxInactiveCol

    protected java.lang.String sessionMaxInactiveCol

Deprecated.
Max Inactive column to use.

#### sessionLastAccessedCol

    protected java.lang.String sessionLastAccessedCol

Deprecated.
Last Accessed column to use.

#### preparedSizeSql

    protected java.sql.PreparedStatement preparedSizeSql

Deprecated.
Variable to hold the `getSize()` prepared statement.

#### preparedSaveSql

    protected java.sql.PreparedStatement preparedSaveSql

Deprecated.
Variable to hold the `save()` prepared statement.

#### preparedClearSql

    protected java.sql.PreparedStatement preparedClearSql

Deprecated.
Variable to hold the `clear()` prepared statement.

#### preparedRemoveSql

    protected java.sql.PreparedStatement preparedRemoveSql

Deprecated.
Variable to hold the `remove()` prepared statement.

#### preparedLoadSql

    protected java.sql.PreparedStatement preparedLoadSql

Deprecated.
Variable to hold the `load()` prepared statement.

### Constructor Detail

#### JDBCStore

    public JDBCStore()

Deprecated.

### Method Detail

#### getName

    public java.lang.String getName()

Deprecated.

Returns:
  the name for this instance (built from container name)

#### getThreadName

    public java.lang.String getThreadName()

Deprecated.

Returns:
  the thread name for this Store.

#### getStoreName

    public java.lang.String getStoreName()

Deprecated.

Overrides:
  `getStoreName` in class `StoreBase`
Returns:
  the name for this Store, used for logging.

#### setDriverName

    public void setDriverName​(java.lang.String driverName)

Deprecated.
Set the driver for this Store.

Parameters:
  `driverName` - The new driver

#### getDriverName

    public java.lang.String getDriverName()

Deprecated.

Returns:
  the driver for this Store.

#### getConnectionName

    public java.lang.String getConnectionName()

Deprecated.

Returns:
  the username to use to connect to the database.

#### setConnectionName

    public void setConnectionName​(java.lang.String connectionName)

Deprecated.
Set the username to use to connect to the database.

Parameters:
  `connectionName` - Username

#### getConnectionPassword

    public java.lang.String getConnectionPassword()

Deprecated.

Returns:
  the password to use to connect to the database.

#### setConnectionPassword

    public void setConnectionPassword​(java.lang.String connectionPassword)

Deprecated.
Set the password to use to connect to the database.

Parameters:
  `connectionPassword` - User password

#### setConnectionURL

    public void setConnectionURL​(java.lang.String connectionURL)

Deprecated.
Set the Connection URL for this Store.

Parameters:
  `connectionURL` - The new Connection URL

#### getConnectionURL

    public java.lang.String getConnectionURL()

Deprecated.

Returns:
  the Connection URL for this Store.

#### setSessionTable

    public void setSessionTable​(java.lang.String sessionTable)

Deprecated.
Set the table for this Store.

Parameters:
  `sessionTable` - The new table

#### getSessionTable

    public java.lang.String getSessionTable()

Deprecated.

Returns:
  the table for this Store.

#### setSessionAppCol

    public void setSessionAppCol​(java.lang.String sessionAppCol)

Deprecated.
Set the App column for the table.

Parameters:
  `sessionAppCol` - the column name

#### getSessionAppCol

    public java.lang.String getSessionAppCol()

Deprecated.

Returns:
  the web application name column for the table.

#### setSessionIdCol

    public void setSessionIdCol​(java.lang.String sessionIdCol)

Deprecated.
Set the Id column for the table.

Parameters:
  `sessionIdCol` - the column name

#### getSessionIdCol

    public java.lang.String getSessionIdCol()

Deprecated.

Returns:
  the Id column for the table.

#### setSessionDataCol

    public void setSessionDataCol​(java.lang.String sessionDataCol)

Deprecated.
Set the Data column for the table

Parameters:
  `sessionDataCol` - the column name

#### getSessionDataCol

    public java.lang.String getSessionDataCol()

Deprecated.

Returns:
  the data column for the table

#### setSessionValidCol

    public void setSessionValidCol​(java.lang.String sessionValidCol)

Deprecated.
Set the `Is Valid` column for the table

Parameters:
  `sessionValidCol` - The column name

#### getSessionValidCol

    public java.lang.String getSessionValidCol()

Deprecated.

Returns:
  the `Is Valid` column

#### setSessionMaxInactiveCol

    public void setSessionMaxInactiveCol​(java.lang.String sessionMaxInactiveCol)

Deprecated.
Set the `Max Inactive` column for the table

Parameters:
  `sessionMaxInactiveCol` - The column name

#### getSessionMaxInactiveCol

    public java.lang.String getSessionMaxInactiveCol()

Deprecated.

Returns:
  the `Max Inactive` column

#### setSessionLastAccessedCol

    public void setSessionLastAccessedCol​(java.lang.String sessionLastAccessedCol)

Deprecated.
Set the `Last Accessed` column for the table

Parameters:
  `sessionLastAccessedCol` - The column name

#### getSessionLastAccessedCol

    public java.lang.String getSessionLastAccessedCol()

Deprecated.

Returns:
  the `Last Accessed` column

#### setDataSourceName

    public void setDataSourceName​(java.lang.String dataSourceName)

Deprecated.
Set the JNDI name of a DataSource-factory to use for db access

Parameters:
  `dataSourceName` - The JNDI name of the DataSource-factory

#### getDataSourceName

    public java.lang.String getDataSourceName()

Deprecated.

Returns:
  the name of the JNDI DataSource-factory

#### getLocalDataSource

    public boolean getLocalDataSource()

Deprecated.

Returns:
  if the datasource will be looked up in the webapp JNDI Context.

#### setLocalDataSource

    public void setLocalDataSource​(boolean localDataSource)

Deprecated.
Set to `true` to cause the datasource to be looked up in the webapp JNDI Context.

Parameters:
  `localDataSource` - the new flag value

#### expiredKeys

    public java.lang.String[] expiredKeys()
                                   throws java.io.IOException

Deprecated.
Description copied from class: `StoreBase`
Get only those keys of sessions, that are saved in the Store and are to be expired.

Overrides:
  `expiredKeys` in class `StoreBase`
Returns:
  list of session keys, that are to be expired
Throws:
  `java.io.IOException` - if an input-/output error occurred

#### keys

    public java.lang.String[] keys()
                            throws java.io.IOException

Deprecated.

Returns:
  an array containing the session identifiers of all Sessions currently saved in this Store. If there are no such Sessions, a zero-length array is returned.
Throws:
  `java.io.IOException` - if an input/output error occurred

#### getSize

    public int getSize()
                throws java.io.IOException

Deprecated.
Return an integer containing a count of all Sessions currently saved in this Store. If there are no Sessions, `0` is returned.

Returns:
  the count of all sessions currently saved in this Store
Throws:
  `java.io.IOException` - if an input/output error occurred

#### load

    public Session load​(java.lang.String id)
                 throws java.lang.ClassNotFoundException,
                        java.io.IOException

Deprecated.
Load the Session associated with the id `id`. If no such session is found `null` is returned.

Parameters:
  `id` - a value of type `String`
Returns:
  the stored `Session`
Throws:
  `java.lang.ClassNotFoundException` - if an error occurs
  `java.io.IOException` - if an input/output error occurred

#### remove

    public void remove​(java.lang.String id)
                throws java.io.IOException

Deprecated.
Remove the Session with the specified session identifier from this Store, if present. If no such Session is present, this method takes no action.

Parameters:
  `id` - Session identifier of the Session to be removed
Throws:
  `java.io.IOException` - if an input/output error occurs

#### clear

    public void clear()
               throws java.io.IOException

Deprecated.
Remove all of the Sessions in this Store.

Throws:
  `java.io.IOException` - if an input/output error occurs

#### save

    public void save​(Session session)
              throws java.io.IOException

Deprecated.
Save a session to the Store.

Parameters:
  `session` - the session to be stored
Throws:
  `java.io.IOException` - if an input/output error occurs

#### getConnection

    protected java.sql.Connection getConnection()

Deprecated.
Check the connection associated with this store, if it's `null` or closed try to reopen it. Returns `null` if the connection could not be established.

Returns:
  `Connection` if the connection succeeded

#### open

    protected java.sql.Connection open()
                                throws java.sql.SQLException

Deprecated.
Open (if necessary) and return a database connection for use by this Store.

Returns:
  database connection ready to use
Throws:
  `java.sql.SQLException` - if a database error occurs

#### close

    protected void close​(java.sql.Connection dbConnection)

Deprecated.
Close the specified database connection.

Parameters:
  `dbConnection` - The connection to be closed

#### release

    protected void release​(java.sql.Connection conn)

Deprecated.
Release the connection, if it is associated with a connection pool.

Parameters:
  `conn` - The connection to be released

#### startInternal

    protected void startInternal()
                          throws LifecycleException

Deprecated.
Start this component and implement the requirements of `LifecycleBase.startInternal()`.

Overrides:
  `startInternal` in class `StoreBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used

#### stopInternal

    protected void stopInternal()
                         throws LifecycleException

Deprecated.
Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.

Overrides:
  `stopInternal` in class `StoreBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used