Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user defined table password field not updating

Status
Not open for further replies.

tlgates

Programmer
May 29, 2003
16
US
Hi all. I have a table that I created that contains user information (e.g. username, password, last name, first name). When I do an insert or an update, the password field is always null and never gets set. The other fields are set but not the password field. Here are the statements that I'm using in my java bean:

sql = "UPDATE user SET username='" + getUsername() + "'," + "password='" + getPassword() + "', " + "lname='" + getLname() + "', " + "fname='" + getFname() + "' WHERE userID = " + ID + ";";

sql = "INSERT INTO user (username, password, lname, fname) " + "VALUES('" + getUsername() + "', '" + getPassword() + "', '" + getLname() + "', '" + getFname() + "');";

I'm new to MySQL. Does it treat that field specially? What can I do to get it to set? When I run the statements in the MySQL SQL Editor, all the fields get set but when I run it in my Java Bean, they don't.

Thanks for your help in advance.
 
The problem is probably in the name you used for your column that stores the password.

The word "password" is a reserved word in MySQL -- it is the name of a MySQL function.

I recommend that you change the name of your column. If it is impossible for you to do that, force MySQL to interpret your use of the word "password" as a name not a function call by enclosing it in backticks:

sql = "INSERT INTO user (username, `password`, lname, fname) " + "VALUES('" + getUsername() + "', '" + getPassword() + "', '" + getLname() + "', '" + getFname() + "');";

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top