Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

editing records in database

 
mike sutton
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is another simple problem that I cannot figure out.
I am trying to edit records in a database. (for example user notices a mistake and wants to correct it.) here is my code

_________________________________________________________________
try {

stmt = l.dbCon.createStatement();
stmt.executeUpdate("UPDATE students SET name LIKE \"" + udstudent + "\" WHERE student_id = \"" + udid );


}
catch (SQLException e) {
res.sendError(res.SC_ACCEPTED, "The request has been accepted, but it failed to complete due to an error updating the database.");
System.out.println(e.toString());
return ;
}
_________________________________________________________________
I keep getting the sql exception. I am sure the problem is in the sql statement, but every variation I try produces the same result.
thanks in advance
Mike
 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LIKE is used to specify a criteria in the WHERE clause. It lets you use the % as a wildcard character. For instance:
where name like 'Bri%'
will match Brian, Brianna, Brigham, etc... It cannot be use after the set statement like you were using it. What are you trying to do and we can help with the SQL
 
mike sutton
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I need to do is change a field in a record.
for example:
If a user is searching the database and notices a name is misspelled (John Doe should be John Dough etc.) or an address needs to be changed.

btw -- still getting same result after the suggested change.

[This message has been edited by mike sutton (edited December 28, 2000).]
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
I give you an example which I used in my web application. Please take a look. This updates the Employe's whose ID=knownID

regds
maha anna
[This message has been edited by maha anna (edited December 28, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic