Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

nested ResultSets

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi every body


i am using nested servlet and it is giving me this error. when i am using single instances of ResultSet and Statement

java.sql.SQLException: Operation not allowed after ResultSet closed


when i am using different instances of ResultSet and Statement

it gives me java.lang.NullPointerException

my code is




here only one object of javabean is able to set into ArrayList and no others

and it gives error: java.sql.SQLException: Operation not allowed after ResultSet closed



in second case

i am using different instances of resultSet and Statement

and no object is set in ArrayList and it gives error : java.lang.NullPointerException



code is




can any one please suggest me the solution.

Thanks and regards.
 
Sheriff
Posts: 67403
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing to do with Servlets; moved to JDBC.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your first example while you are iterating through your results set you reassing the variable rs to another results set. That is never going to work.

What line does the NullPointerException occur on?
 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

true ..in first case the resultSet rs is being reassigned.
but ,then second case should work.
In second case it is giving nullPointer exception.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In second case it is giving nullPointer exception





it will throw definitely. where is st1 initialized ?
 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is initiallised at the start of this function.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

it is initiallised at the start of this function.



where is the relevant code for that ? Check again , its not initialized. only st is initialized , not st1.
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic