Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

urgent help needed!!

 
arpit singla
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have logservlet. I have this connection object, retrieving data from database. This connection object has autocommit=false I am able to display the rows in my System.out.println within while loop. I am setting the resultset obtained from this retrieval into session and passing onto jsp. But I am not able to display the rows from this resultset.
I guess but not sure this is because my statement object is autocommit=false.
when i take out autocommit=false from the statement object, i get error
"ResultSet not open, operation next not permitted. Verify that autocommit is OFF"
way i am creating my statement object is:
Connection connect1 = DriverManager.getConnection("jdbc:cloudscape:c:/cloudscape/onlineshop;autocommit=false");
/* code */
ResultSet choicebookresult = null;
/* code */
Statement stmtchoice = connect1.createStatement();
String querychoice = "SELECT BOOKNAME,AUTHOR FROM BOOKS WHERE ID IN( 1,2,3,4,5 ) AND CHOICEBOOK=true" ;
System.out.println(querychoice);
choicebookresult = stmtchoice.executeQuery(querychoice);
String author = null;
String bookname = null;
while(choicebookresult.next())
{
author = choicebookresult.getString("AUTHOR");
bookname = choicebookresult.getString("BOOKNAME");
System.out.println(" the bookname " + bookname);
System.out.println(" the author " + author);
}
/* code */
session.setAttribute("choicebooks",choicebookresult);

 
kvk kishore
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arpit ,
Why don't you pass Hashtable or Vector in place of resultset . Or try the Service to Worker Model .

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's kind of problematic to pass a resultset to a JSP page, and you've discovered why.

Resultsets cannot be removed from their connection. So when you pass a resultset to a JSP you've sort of done that. The connection didn't move along with it.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic