JETTY-1263 fix the previous fix so that existing tables are not affected
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2264 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
5d49fe9d29
commit
2c16ef1fc1
|
@ -60,6 +60,8 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
protected String _jndiName;
|
||||
protected String _sessionIdTable = "JettySessionIds";
|
||||
protected String _sessionTable = "JettySessions";
|
||||
protected String _sessionTableRowId = "rowId";
|
||||
|
||||
protected Timer _timer; //scavenge timer
|
||||
protected TimerTask _task; //scavenge task
|
||||
protected long _lastScavengeTime;
|
||||
|
@ -124,6 +126,11 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
return identifier;
|
||||
}
|
||||
|
||||
public String getDBName ()
|
||||
{
|
||||
return _dbName;
|
||||
}
|
||||
|
||||
public String getBlobType ()
|
||||
{
|
||||
if (_blobType != null)
|
||||
|
@ -423,7 +430,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
}
|
||||
super.doStop();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a connection from the driver or datasource.
|
||||
*
|
||||
|
@ -481,6 +488,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
connection.setAutoCommit(true);
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
_dbAdaptor = new DatabaseAdaptor(metaData);
|
||||
_sessionTableRowId = (_dbAdaptor.getDBName() != null && _dbAdaptor.getDBName().contains("oracle") ? "srowId":_sessionTableRowId);
|
||||
|
||||
//checking for table existence is case-sensitive, but table creation is not
|
||||
String tableName = _dbAdaptor.convertIdentifier(_sessionIdTable);
|
||||
|
@ -498,10 +506,10 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
{
|
||||
//table does not exist, so create it
|
||||
String blobType = _dbAdaptor.getBlobType();
|
||||
_createSessionTable = "create table "+_sessionTable+" (srowId varchar(120), sessionId varchar(120), "+
|
||||
_createSessionTable = "create table "+_sessionTable+" ("+_sessionTableRowId+" varchar(120), sessionId varchar(120), "+
|
||||
" contextPath varchar(60), virtualHost varchar(60), lastNode varchar(60), accessTime bigint, "+
|
||||
" lastAccessTime bigint, createTime bigint, cookieTime bigint, "+
|
||||
" lastSavedTime bigint, expiryTime bigint, map "+blobType+", primary key(srowId))";
|
||||
" lastSavedTime bigint, expiryTime bigint, map "+blobType+", primary key("+_sessionTableRowId+"))";
|
||||
connection.createStatement().executeUpdate(_createSessionTable);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
protected String __updateSession;
|
||||
protected String __updateSessionNode;
|
||||
protected String __updateSessionAccessTime;
|
||||
protected String __sessionTableRowId;
|
||||
|
||||
private ConcurrentHashMap _sessions;
|
||||
protected long _saveIntervalSec = 60; //only persist changes to session access times every 60 secs
|
||||
|
@ -806,24 +807,26 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
|
||||
protected void prepareTables ()
|
||||
{
|
||||
__sessionTableRowId = ((JDBCSessionIdManager)_sessionIdManager)._sessionTableRowId;
|
||||
|
||||
__insertSession = "insert into "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
||||
" (srowId, sessionId, contextPath, virtualHost, lastNode, accessTime, lastAccessTime, createTime, cookieTime, lastSavedTime, expiryTime, map) "+
|
||||
" ("+__sessionTableRowId+", sessionId, contextPath, virtualHost, lastNode, accessTime, lastAccessTime, createTime, cookieTime, lastSavedTime, expiryTime, map) "+
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
__deleteSession = "delete from "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
||||
" where srowId = ?";
|
||||
" where "+__sessionTableRowId+" = ?";
|
||||
|
||||
__selectSession = "select * from "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
||||
" where sessionId = ? and contextPath = ? and virtualHost = ?";
|
||||
|
||||
__updateSession = "update "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
||||
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ?, map = ? where srowId = ?";
|
||||
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ?, map = ? where "+__sessionTableRowId+" = ?";
|
||||
|
||||
__updateSessionNode = "update "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
||||
" set lastNode = ? where srowId = ?";
|
||||
" set lastNode = ? where "+__sessionTableRowId+" = ?";
|
||||
|
||||
__updateSessionAccessTime = "update "+((JDBCSessionIdManager)_sessionIdManager)._sessionTable+
|
||||
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ? where srowId = ?";
|
||||
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ? where "+__sessionTableRowId+" = ?";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -848,7 +851,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
if (result.next())
|
||||
{
|
||||
data = new SessionData(id);
|
||||
data.setRowId(result.getString("srowId"));
|
||||
data.setRowId(result.getString(__sessionTableRowId));
|
||||
data.setCookieSet(result.getLong("cookieTime"));
|
||||
data.setLastAccessed(result.getLong("lastAccessTime"));
|
||||
data.setAccessed (result.getLong("accessTime"));
|
||||
|
|
Loading…
Reference in New Issue