Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while retrieving column from database

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set an attribute named USER, whose values are retrieved through a html, depending upon the user. In this jsp i need to change the password. 't1','t2','t3' are getting old password, new password & confirm password field from html.

First i am checking whether old password field and password column in database has same value.

For updating the password i am retrieving ID no also from the table. (My all tables has ID,username, and password column)

But, while retrieving ID , its showing the error, "Invalid column name". Even the index number (instead of "ID") is not working and showing the error "INVALID COLUMN NUMBER"



 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure in your query..



I'm wondering that "you have separate tables for each user". If its not like that, then please check in your query, you have put the user name in the place of table name.Are you sure,"is that right"?
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's right. I am having different tables with "USER's " name.
Error is on Line no.41. (as checked via println statements)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Your SELECT says : "select password". You're not getting any ID here. Did you want to do something like "select id, password..." ?
2. Are you sure that the name of the table is set in a session attribute called "user" ??
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes , i am not getting any ID here. I am just checking for same password, If it is found, then i am getting the ID.
Yes, i am sure that the name of the table is set in a session attribute called "user".
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is found, then i am getting the ID.

No, you're not getting the ID. Where's the SELECT clause which retrieves the ID ?
 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why can't you change your select query as " select id,password from ... ". then you check your db password to user entered password..
 
Pawan Kr Gupta
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I agrred with Bharath ,

You should change your query first , then it will work .I think this is not an example of good code because you code could be effected by SQL injection.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
err... why are you establishing a connection through a JSP page ?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4008
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel the need to post a link to this again Why JDBC + JSP = Bad. Please consider refactoring!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic