java.sql.SQLException: Operation not allowed after ResultSet closed
843836Jul 15 2005 — edited Jul 20 2007Hello to all,
this is my first message in this forum ; )
I encountered this problem that is making me crazy...
When I try to run a JSP filling a form with some letters, it says
java.sql.SQLException: Operation not allowed after ResultSet closed
...but the real problem is that this application works with friend of mine:
the only differences between us are that I use JDK 5.0 with Tomcat 5.5.9, and he use Jdk 4 and tomcat 4
This is the "problematic Bean" code
/*
* Created on 4-giu-2005
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package Viag;
import java.sql.*;
/**
* @author Davide
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class ListViag {
private String citta="";
private String stato="";
private Connection con;
private Statement st;
private ResultSet res;
public ListViag() throws Exception{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/turismo","root","pizzo");
st=con.createStatement();
res=null;
}
public boolean execute() {
try {
this.res=st.executeQuery("SELECT Id, Nomeagenzia FROM viaggio WHERE (Nomecitta='"+citta+"' AND Stato='"+stato+"')");
con.close();
return true;
}
catch(Exception e){return false;}
}
public boolean next() throws Exception{
if(res.next())
return true;
return false;
}
public String getId() throws Exception{
return res.getString("Id");
}
public String getNomeAg() throws Exception{
return res.getString("Nomeagenzia");
}
public void setCitta(String c){
this.citta=c;
}
public void setStato(String s){
this.stato=s;
}
public String getCitta(){
return this.citta;
}
public String getStato(){
return this.stato;
}
}