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

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: 42003
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,
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: 42003
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

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.
 
I don't always make ads but when I do they're tiny
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic