This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes nested ResultSets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "nested ResultSets" Watch "nested ResultSets" New topic
Author

nested ResultSets

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

Nothing to do with Servlets; moved to JDBC.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
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.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


In second case it is giving nullPointer exception




it will throw definitely. where is st1 initialized ?
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
it is initiallised at the start of this function.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


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 agree. Here's the link: http://aspose.com/file-tools
 
subject: nested ResultSets
 
Similar Threads
Geting an SQL Exception while passing the resultset to a bean
problem in inserting data
problem in accesing a db from a servlet
RowMapper callback interface's mapRow can pull only one row?
Exception in thread "main" java.sql.SQLException