aspose file tools*
The moose likes JDBC and the fly likes Show only one record instead of specific record when onclick Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Show only one record instead of specific record when onclick" Watch "Show only one record instead of specific record when onclick" New topic
Author

Show only one record instead of specific record when onclick

Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Posts: 51
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





Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Posts: 51
I see i see.
But when I change the statement to :SELECT * FROM products where ProductId = '?' "

The text field will be empty


[Thumbnail for impt.jpg]

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Show only one record instead of specific record when onclick