The need for this comes when you run multiple webapps which each may have classes in session that are unique to the webapp. As written, JDBCStore tries to pull all webapps from the database regardless of who generated them. Exceptions ensue.
With this patch, a webapp will only read and write sessions that belong to it. I much prefer this to creating multiple tomcat$session tables because of the testing and maintenance aspects. Hopefully somebody will agree enough to consider applying this patch.
Cheers,
~Tom
p.s. With all the fixes I've submitted, my version of Tomcat has a much more stable implementation of JDBCStore than the controlled version ... good for me but bad for everyone else ... what's the trick to getting the patches accepted?
Index: JDBCStore.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/JDBCStore.java,v retrieving revision 1.9 diff -r1.9 JDBCStore.java 11c11 < * Copyright (c) 1999 The Apache Software Foundation. All rights --- > * Copyright (c) 1999, 2003 The Apache Software Foundation. All rights 82a83 > import java.util.ArrayList; 125a127,131 > > /** > * name associated with this app > */ > private String myName = null; 144a151,155 > * App column to use. > */ > protected String sessionAppCol = "app"; > > /** 219a231,245 > * Return the name for this instance (built from container name) > */ > public String getName() { > if (myName == null) { > Container container = manager.getContainer(); > if (container.getParent() == null) { > myName = container.getName(); > } else { > myName = container.getParent().getName() + container.getName(); > } > } > return myName; > } > > /** 300a327,346 > * Set the App column for the table. > * > * @param sessionAppCol the column name > */ > public void setSessionAppCol(String sessionAppCol) { > String oldSessionAppCol = this.sessionAppCol; > this.sessionAppCol = sessionAppCol; > support.firePropertyChange("sessionAppCol", > oldSessionAppCol, > this.sessionAppCol); > } > > /** > * Return the Id column for the table. > */ > public String getSessionAppCol() { > return(this.sessionAppCol); > } > > /** 391,393c437,438 < "SELECT COUNT(s."+sessionIdCol+"), c."+sessionIdCol+ < " FROM "+sessionTable+" s, "+sessionTable+" c"+ < " GROUP BY c."+sessionIdCol; --- > "SELECT "+sessionIdCol+" FROM "+sessionTable + > " WHERE " + sessionAppCol + " = ?"; 406a452 > preparedKeysSql.setString(1, getName()); 408,414c454,460 < if (rst != null && rst.next()) { < keys = new String[rst.getInt(1)]; < keys[0] = rst.getString(2); < i=1; < < while(rst.next()) < keys[i++] = rst.getString(2); --- > if (rst != null) { > ArrayList ids = new ArrayList(); > while(rst.next()) { > String id = rst.getString(1); > ids.add(id); > } > keys = (String[])ids.toArray(new String[ids.size()]); 445c491,492 < ") FROM ".concat(sessionTable); --- > ") FROM ".concat(sessionTable) + > " WHERE " + sessionAppCol + " = ?"; 455a503 > preparedSizeSql.setString(1, getName()); 497c545 < " WHERE "+sessionIdCol+" = ?"; --- > " WHERE "+sessionIdCol+" = ? AND " + sessionAppCol + " = ?"; 506a555 > preparedLoadSql.setString(2, getName()); 630a680 > sessionAppCol+", "+ 634c684 < sessionLastAccessedCol+") VALUES (?, ?, ?, ?, ?)"; --- > sessionLastAccessedCol+") VALUES (?, ?, ?, ?, ?, ?)"; 665,668c715,719 < preparedSaveSql.setBinaryStream(2, in, size); < preparedSaveSql.setString(3, session.isValid()?"1":"0"); < preparedSaveSql.setInt(4, session.getMaxInactiveInterval()); < preparedSaveSql.setLong(5, session.getLastAccessedTime()); --- > preparedSaveSql.setString(2, getName()); > preparedSaveSql.setBinaryStream(3, in, size); > preparedSaveSql.setString(4, session.isValid()?"1":"0"); > preparedSaveSql.setInt(5, session.getMaxInactiveInterval()); > preparedSaveSql.setLong(6, session.getLastAccessedTime());
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]