• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Error while retrieving column from database

 
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"



 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
err... why are you establishing a connection through a JSP page ?
 
author
Posts: 4323
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel the need to post a link to this again Why JDBC + JSP = Bad. Please consider refactoring!
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic