• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updateable ResultSet() not updating

 
Bryan Scarbrough
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write an updateable result set that takes in multiple values from a JSP page and updates the ResultSet. I am posting these values to a Servlet that then sets the appropriate variable values and I then perform the query and "attempt" to use an if() statement to compare current database values with the new variables and thus only update the values that require updating, but it is not working at all!

Below is the code that I am using for my ResultSet and it is not working at all!



Can someone please help me to figure out what is wrong with this code or if I am trying to do this all wrong in the first place?!

Thanks!
 
Bryan Scarbrough
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have also tried this without the IF() statements, simply updating everything all at once, and it still does not work!!

Please help!!
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is result.next() returning false?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
}catch(Exception e) {
e.printStackTrace();
}


and I'm assuming there is no stack trace?
 
Bryan Scarbrough
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and I'm assuming there is no stack trace?


Nope, no visible errors being reported! The form values are posted to a JavaBean and the servlet then redirects back to the original page. The info goes out...somewhere...and then the page refreshes as it posts back to itself.


Is result.next() returning false?


If the ResultSet returned null, wouldn't I get an error? Anyway, I am using a query very similar to this one in another Bean and it works perfectly; I have not tried to update with that query, however...

I think I may just resort to plain old SQL for the Update. I am quickly running out of time for this project, so I must work with what I know and understand.

Thanks for your help, if you think of anything else, please let me know as I would like to implement this in future projects if possible - plus I hate not being able to resolve a problem like this!!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bryan Scarbrough:
If the ResultSet returned null, wouldn't I get an error?

ResultSets never return null. Dave meant false as in your loop never gets executed because the select doesn't return anything. Try putting a println right after "while (result.next()) {" to see if this is the case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic