• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in returning data using resultset

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear,
Im trying to retrive some information using select query and then pass the result set to another program. While running i got the error saying that the resultset is closed and can not have access. so I cleaned any pstmt.close or con.close . But still it throws me the same error. Do you know where is the problem? Here i copy the SELEC and TRIGGER classes and the error.
////////////Select///////////


//////// a piece of trigger class///////


////////////and here is the error/////////

java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)

Do you know how can i solve it?
Thank you so much,
Sahar.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sahar sa,

Can you please format the code using "code" tags (you can do it by editing your post just put the code inside "[code]" tags). Unformatted code is very hard to read.

 
sahar sa
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your explanation, I think now is formatted?! ;)
 
sahar sa
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends!
any idead about this error please?

thnx,
Sahar.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read this -
"A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results."

 
sahar sa
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear,
But I did'nt close any statement or connection and I did'nt re-execute it (you can check the code above!)
So remains third option "retriving next result from a sequence of multiple result". I searched many about this but I'm still confuse that a simple select does have a sequence of multiple result. I think no!
1) Am I right?
2) If Im right what is wrong then?

thank you so much!
Sahar.
 
vikram Kesav
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure that something somewhere (your connection pool, for example) isn't executing
another query on the given statement? _Something_ is closing that result set, either it's
explicitly closed, or it's being closed by the fact that the statement has either had
another query executed on it, or the statement itself has been closed, either explicitly
or by the Connection that created it being closed.

See everytime you execute the statement, all open resultsets will be closed. There is no way around that.

So, you will have to read the entire resultset and save the results, then loop through those results, setting of the query again for the "next level down/up" and, once again, reading in the entire result set etc.

Else, you need to create a new statement object instead of PrepareStatement.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic