tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Fray <f...@itcf.biz>
Subject Re: Bug report
Date Thu, 17 Aug 2006 18:54:45 GMT
Hi Dimitri,

forget this one, I should read the postings completely before responding :-)
So Charly is completely right with his assumption.

Regards,

Florian

Florian Fray schrieb:
> Hi Dimitri,
>
> this is not a Tomcat bug, but look at the second "rs = 
> stmt.executeQuery();"
> You closed this "stmt" few lines before and I think you intended to 
> call "rs = stmt_jeucode.executeQuery();" instead.
>
> Regards,
>
> Florian
>
>
> Dimitri Piriou schrieb:
>> Hello,
>>  
>> Sorry if I don't post at the right place but I'm sending you this 
>> mail to
>> make a bug (I think that is one) report. I'm developping a servlet and a
>> mistake made Tomcat stopping each time my code had to be executed. An
>> exception was thrown before and here is the extract of Tomcat log file:
>>  
>> java.sql.SQLException: No operations allowed after statement closed
>>  
>> There was, indeed, an error in my code and I used a preparedStatement 
>> I had
>> already closed but is it normal that Tomcat stopped?
>>
>> Here is my source code:
>>  
>> ----------------------------------------------------------------------
>> protected void doPost(HttpServletRequest request, HttpServletResponse
>> response) throws ServletException, IOException {
>>       response.setStatus( HttpServletResponse.SC_OK );
>>      response.setContentType( "text/vnd.wap.wml" );
>>      ServletOutputStream out = response.getOutputStream();
>>      int code_id = Integer.parseInt(request.getParameter("code_id"));
>>      out.println("<?xml version=\"1.0\"?>");
>>      out.println("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 
>> 1.1//EN\" \"
>> <BLOCKED::http://www.wapforum.org/DTD/wml_1.1.xml\>
>> http://www.wapforum.org/DTD/wml_1.1.xml\">");
>>      try{
>>          Class.forName("com.mysql.jdbc.Driver").newInstance();
>>          java.sql.Connection conn = 
>> java.sql.DriverManager.getConnection(
>>            "jdbc:mysql://localhost/bd?user=user&password=password");
>>          String useragent = request.getHeader("User-Agent");
>>          PreparedStatement stmt = conn.prepareStatement("SELECT DISTINCT
>> nom1_id, nom1, nom2 FROM device NATURAL JOIN nom1 INNER JOIN nom2 ON
>> nom2.nom2_id = nom1.nom2_id WHERE phone_user_agent = ?");
>>          stmt.setString(1, useragent);
>>          ResultSet rs = stmt.executeQuery();
>>          String nom1 = "";
>>          String nom2= "";
>>                   while (rs.next()) {
>>           nom1 = rs.getString("nom1");
>>           nom2 = rs.getString("nom2");
>>       }
>>          stmt.close();
>>          PreparedStatement stmt_jeucode = 
>> conn.prepareStatement("SELECT code
>> FROM codes WHERE code_id = ?");
>>          stmt_jeucode.setInt(1, code_id);
>>          rs = stmt.executeQuery(); // Exception levée ici
>>          String code = "";
>>          while (rs.next()) {
>>           code = rs.getString("code");
>>          }
>>          String toPrint = "gal" + code_id + "_" + code + "_" + nom2 + 
>> "_" +
>> nom1 + ".jar";
>>       out.println("<wml><card id=\"toto\" title=\"doPost\"><p>"
+ 
>> toPrint +
>> " doPost</p></card></wml>");
>>  
>>  
>>      } catch(Exception e){
>>          System.err.println("Connection ratée: "+e);
>>          System.exit(-1);       }
>>      out.close();
>>  }
>> ----------------------------------------------------------------------
>>  
>>  
>> Best Regards,
>>  
>> Dimitri Piriou
>> Axellance, France
>>
>>   
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message