Refering to Bug#7170 and Bug#4961.

The original src try to join table but result in
illegal group-by expression (in Oracle DB). And it
also hinder the performance by joining table.

Instead of using count(session_id) to get the total
number of sessions, I propose to use ArrayList to hold
the session_ids, then return it as String[].

I also add some pointer checking to avoid
NullPointerException in stop()

Patch is attached in the email.


_________________________________________________________
Do you Yahoo!?
至Hit手機鈴聲 全城火熱下載
Download the HOTTEST ringtones from Yahoo!
http://ringtone.yahoo.com.hk
Index: JDBCStore.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/JDBCStore.java,v
retrieving revision 1.4
diff -u -r1.4 JDBCStore.java
--- JDBCStore.java      22 Jul 2001 20:25:12 -0000      1.4
+++ JDBCStore.java      17 Mar 2002 04:38:32 -0000
@@ -75,6 +75,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamClass;
+import java.util.ArrayList;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
@@ -388,9 +389,9 @@
      */
     public String[] keys() throws IOException {
         String keysSql =
-            "SELECT COUNT(s."+sessionIdCol+"), s."+sessionIdCol+
-            " FROM "+sessionTable+" s, "+sessionTable+" c"+
-            " GROUP BY c."+sessionIdCol;
+                       //Try to fix the invalid group by expression
+            "SELECT s."+sessionIdCol+
+            " FROM "+sessionTable+" s";
 
         Connection _conn = getConnection();
         ResultSet rst = null;
@@ -406,12 +407,10 @@
 
             rst = preparedKeysSql.executeQuery();
             if (rst != null && rst.next()) {
-                keys = new String[rst.getInt(1)];
-                keys[0] = rst.getString(2);
-                i=1;
-
+                               ArrayList tmpkeys = new ArrayList();
                 while(rst.next())
-                    keys[i++] = rst.getString(2);
+                                       tmpkeys.add(rst.getString(1));
+                               keys = (String[]) tmpkeys.toArray(new 
+String[tmpkeys.size()]);
             } else {
                 keys = new String[0];
             }
@@ -758,41 +757,53 @@
                 ;
             }
 
-            try {
-                preparedSizeSql.close();
-            } catch (SQLException e) {
-                ;
-            }
-
-            try {
-                preparedKeysSql.close();
-            } catch (SQLException e) {
-                ;
-            }
-
-            try {
-                preparedSaveSql.close();
-            } catch (SQLException e) {
-                ;
-            }
-
-            try {
-                preparedClearSql.close();
-            } catch (SQLException e) {
-                ;
-            }
-
-            try {
-                preparedRemoveSql.close();
-            } catch (SQLException e) {
-                ;
-            }
-
-            try {
-                preparedLoadSql.close();
-            } catch (SQLException e) {
-                ;
-            }
+                       if(preparedSizeSql != null) {
+                               try {
+                                       preparedSizeSql.close();
+                               } catch (SQLException e) {
+                                       ;
+                               }
+                       }
+
+                       if(preparedKeysSql != null) {
+                               try {
+                                       preparedKeysSql.close();
+                               } catch (SQLException e) {
+                                       ;
+                               }
+                       }
+
+                       if(preparedSaveSql != null) {
+                               try {
+                                       preparedSaveSql.close();
+                               } catch (SQLException e) {
+                                       ;
+                               }
+                       }
+
+                       if(preparedClearSql != null) {
+                               try {
+                                       preparedClearSql.close();
+                               } catch (SQLException e) {
+                                       ;
+                               }
+                       }
+
+                       if(preparedRemoveSql != null) {
+                               try {
+                                       preparedRemoveSql.close();
+                               } catch (SQLException e) {
+                                       ;
+                               }
+                       }
+
+                       if(preparedLoadSql != null) {
+                               try {
+                                       preparedLoadSql.close();
+                               } catch (SQLException e) {
+                                       ;
+                               }
+                       }
 
             try {
                 conn.close();

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to