Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Update the whole info in database instead of one.

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, I have a problem regarding on updating in database using jsp and servlets.

The problem is when I update it will update the whole records instead on the specific records I choose to update. Like I update yellow beanie color from "green to yellow".
It update all the color to be the same one as well as other details:(

do you know what happen?

This is my code in servlet:



This is my update form in jsp using dojox:)



Thanks for your help in all this while.

I really appreciate it:)
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

What is the primary key for the table you are updating ?

is it UserId or ProductId ?

Since you are saying that update is working, so, it seems to be a problem with the query.



 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh the primary key is ProductId:)
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Change your query to



If you want to update products based on userid then


This will solve your issue..
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask JDBC questions in the JDBC forum. I have moved this post there for you.
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

Howerver there seems to be error. It explains that :Syntax error on token(s), misplaced construct(s)
, when I debug:(

Is there anything wrong with this?



Thanks for your help all this while:D
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Loh,
The prepared statement code looks fine. It's much more likely the error is in your SQL string. Can you post the updated one you are using?
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah sure:)

This is the one i am currently using:)




Is this the correct statement that allows me to update all value regarding on product except UserId
However when I update it will show something Syntax error on token(s), misplaced construct(s) when I debug:(
Thanks:)
 
Jeanne Boyarsky
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. The SQL looks right. You might try moving the "set" for parameter 8 to the end. There's no rule that says they have to be set in order, but you never know.

As far as debugging goes, does it work if you just update one column? Two columns? etc. Finding the smallest statement that gives the error will help in narrowing it down.
 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you have to remove the 'space' inside your PreparedStatement..

please try this Statement..


Correct me if im wrong..

Hope this help..
 
reply
    Bookmark Topic Watch Topic
  • New Topic