Bonjour,

J'ai un problème qui me fait tourner un peu la tête.
J'ai développé un forum de discussion sous TOMCAT 5.5.11 et j'ai utilisé la technique de pool de connexion comme mentionné dans le tutoriel du site.
Tout allait bien. lorsque j'ai mis le site sous TOMCAT 5.5.12, la page du forum ne veut plus s'afficher et j'ai l'erreur suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
java.sql.SQLException: After end of result set
    com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:672)
    com.mysql.jdbc.ResultSet.getInt(ResultSet.java:2241)
    org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:186)
    org.apache.jsp.forum_jsp._jspService(org.apache.jsp.forum_jsp:543)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Il se peut que ce que j'ai développé est erroné.
J'ai développé un composant DbBean pour la connexion à la base :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
public class DbBean {
 
  Connection  dbCon        = null;
  Statement   stmt         = null;
  ResultSet   rset         = null;
  DataSource ds;
 
 
  public void connect() {
    try{
        InitialContext ic = new InitialContext();
 
         ds = (DataSource)ic.lookup("java:comp/env/jdbc/base");
 
        dbCon  = ds.getConnection();
    } catch (SQLException se) {
        System.out.println("SQL Error while connecting to the database : "+
                            se.toString());
 
    } catch (NamingException ne) {
        System.out.println("Naming exception Error while connecting to the database : "+
                            ne.toString());
    } catch (Exception ne) {
        System.out.println("Other Error while connecting to the database : "+
                            ne.toString());
    }
  }
 
 
  public ResultSet execSQL(String sql) {
 
    // Get the database connection
 
    try{
         stmt = dbCon.createStatement();
         rset = stmt.executeQuery(sql);
 
 
       } catch (SQLException e) {
 
       }
     return rset;
  }
 
 public void execUpdate(String sql)
  {
       PreparedStatement stmt = null;
 
    try
     {
        stmt  = dbCon.prepareStatement(sql.toString());
         stmt.executeUpdate();
 
 
       } catch (SQLException e) {
 
       }
}
 
 
 public void close()
 {
 try {
 
        // Close resultset,statements and connection.
        if (rset!= null) {rset.close();rset=null;}
        if (stmt!= null) {stmt.close();stmt=null;}
        if (dbCon!= null) {dbCon.close();dbCon=null;}
       } catch (Exception e) {       
       }
                finally {
            // Always make sure result sets and statements are closed,
            // and the connection is returned to the pool
            if (rset != null) {
              try { rset.close(); } catch (SQLException e) { ; }
              rset = null;
            }
            if (stmt != null) {
              try { stmt.close(); } catch (SQLException e) { ; }
              stmt = null;
            }
            if (dbCon != null) {
              try { dbCon.close(); } catch (SQLException e) { ; }
              dbCon = null;
            }
          }
 
 }
}
dans la page forum.jsp, je fais appel à des fonctions (déclarés dans la page elle même) dont chacune contient une requête vers la base.
La page contien à peu près le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
<jsp:useBean id = "db" scope = "page" class = "DbBean" />
 
<%
try
{
db.connect();
 
getCountForum(db);
...
}
catch(SQLException e){}
finally
{
db.close();
}
%>
<%!
public int getCountForum(DbBean db) throws SQLException
{
int result = 0;
String sqlt = "SELECT count(*) FROM forum WHERE id_forum != 1";
 
ResultSet rst = db.execSQL(sqlt);
if(rst.next())
 result = rst.getInt(1);
 
return result;
}
...
%>
Je ne trouve pas de solution car tout marchait trop bien sous TOMCAT 5.5.11. J'utilise les mêmes package commons de TOMCAT.
bien sûr, j'ai bien configuré context.xml
Prière de m'aider car je dois héberger le site le plus tôt possible.

Merci