You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "L. Sam" <ls...@covad.net> on 2003/05/22 05:25:00 UTC

Problems with ResultSets

I'm not sure if it's my Tomcat cofiguration that's gone haywire, but 
ResultSets seem to close as soon as they're opened. It was basically 
working an hour ago, and all I've done in the meantime is install the 
Lucene demo....
At this point, I have no idea what's going wrong.

I have really simple code where Tomcat/JSP uses a JDBC connector to 
interact with MySQL. It looks like this:

Query db = new Query();
db.init();
ResultSet r = db.getResultSet("select * from Users");
while(r.next()) {
       [do whatever....]
}
r.close();

It seems that when it hits r.next(), it throws some sort of exception 
which I've been unable to figure out. Specifically, 
"org.apache.jasper.JasperException: Operation not allowed after 
ResultSet closed"

Sorry about all the code, but I figured that it was the only way to 
explain the issue. The code i'm inlcuding here is basically what gets 
done (the actual implementation is a little long).

Query is nothing more than a class that holds a data connection with 
private Connection conn;:
init(){
    Context ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Project");
    conn = ds.getConnection();
}

ResultSet getResultSet(String sql) {
    ResultSet r = null;
    Statement s = conn.createStatement();
    r = s.executeQuery(sql);
    r.close();
    return r;
}


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


Re: Problems with ResultSets

Posted by "L. Sam" <ls...@covad.net>.
I jsut changed it recompiled, and then relaoded the webapp in Tomcat 
manager. Still have the same issue. Thanks for the help - I'm totally at 
a dead end here.


Tim Funk wrote:

> "ResultSet getResultSet(String sql)" closes your result set before you 
> use it in the while loop.
>
> -Tim
>
> L. Sam wrote:
>
>> I'm not sure if it's my Tomcat cofiguration that's gone haywire, but 
>> ResultSets seem to close as soon as they're opened. It was basically 
>> working an hour ago, and all I've done in the meantime is install the 
>> Lucene demo....
>> At this point, I have no idea what's going wrong.
>>
>> I have really simple code where Tomcat/JSP uses a JDBC connector to 
>> interact with MySQL. It looks like this:
>>
>> Query db = new Query();
>> db.init();
>> ResultSet r = db.getResultSet("select * from Users");
>> while(r.next()) {
>>       [do whatever....]
>> }
>> r.close();
>>
>> It seems that when it hits r.next(), it throws some sort of exception 
>> which I've been unable to figure out. Specifically, 
>> "org.apache.jasper.JasperException: Operation not allowed after 
>> ResultSet closed"
>>
>> Sorry about all the code, but I figured that it was the only way to 
>> explain the issue. The code i'm inlcuding here is basically what gets 
>> done (the actual implementation is a little long).
>>
>> Query is nothing more than a class that holds a data connection with 
>> private Connection conn;:
>> init(){
>>    Context ctx = new InitialContext();
>>    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Project");
>>    conn = ds.getConnection();
>> }
>>
>> ResultSet getResultSet(String sql) {
>>    ResultSet r = null;
>>    Statement s = conn.createStatement();
>>    r = s.executeQuery(sql);
>>    r.close();
>>    return r;
>> }
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>



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


Re: Problems with ResultSets

Posted by Tim Funk <fu...@joedog.org>.
"ResultSet getResultSet(String sql)" closes your result set before you use it 
in the while loop.

-Tim

L. Sam wrote:
> I'm not sure if it's my Tomcat cofiguration that's gone haywire, but 
> ResultSets seem to close as soon as they're opened. It was basically 
> working an hour ago, and all I've done in the meantime is install the 
> Lucene demo....
> At this point, I have no idea what's going wrong.
> 
> I have really simple code where Tomcat/JSP uses a JDBC connector to 
> interact with MySQL. It looks like this:
> 
> Query db = new Query();
> db.init();
> ResultSet r = db.getResultSet("select * from Users");
> while(r.next()) {
>       [do whatever....]
> }
> r.close();
> 
> It seems that when it hits r.next(), it throws some sort of exception 
> which I've been unable to figure out. Specifically, 
> "org.apache.jasper.JasperException: Operation not allowed after 
> ResultSet closed"
> 
> Sorry about all the code, but I figured that it was the only way to 
> explain the issue. The code i'm inlcuding here is basically what gets 
> done (the actual implementation is a little long).
> 
> Query is nothing more than a class that holds a data connection with 
> private Connection conn;:
> init(){
>    Context ctx = new InitialContext();
>    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Project");
>    conn = ds.getConnection();
> }
> 
> ResultSet getResultSet(String sql) {
>    ResultSet r = null;
>    Statement s = conn.createStatement();
>    r = s.executeQuery(sql);
>    r.close();
>    return r;
> }
> 


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