• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Show only one record instead of specific record when onclick

 
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 am facing a huge problem in my update form:(

Like when I click on 1101, it show the records of 1101 to be updated.
But when I click on 1102, it still show the 1101 record instead of 1102. Which mean whatever product I click on it will still be the same 1101 record:(
My servlets codes are:



My jsp code is:


My database attribitues are:
ProductId
ProdName
ProdColor
ProdDesc
UnitPrice
Quantity
ProdCatId
UserId
ProductImage

Thanks:)

I need it urgently.
You guys are a great help to me!
Really:D





 
author & internet detective
Posts: 41860
908
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,
I don't see a where clause in your JSP. Doesn't that just make it always write out the first record in the database?

As an aside, it's not considered good practice to have JDBC code in a JSP.
 
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
I see i see.
But when I change the statement to :SELECT * FROM products where ProductId = '?' "

The text field will be empty:(
impt.jpg
[Thumbnail for impt.jpg]
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
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

SELECT * FROM products where ProductId = '?'



I can think of a couple causes:
1) You shouldn't have the single quotes around the '?'. PreparedStatements take care of that for you and it could cause the database confusing.
2) Is there whitespace in the id in the database? If so, you'll need to call trim() in your SQL statement.

Also, does that query return no data for record 1001 as well or just 1002? The answer will narrow down the field of problems a bit.
 
You got style baby! More than this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic