my dog learned polymorphism*
The moose likes JDBC and the fly likes editing records in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "editing records in database" Watch "editing records in database" New topic
Author

editing records in database

mike sutton
Greenhorn

Joined: Dec 07, 2000
Posts: 14
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

Joined: Nov 02, 2000
Posts: 195
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

Joined: Dec 07, 2000
Posts: 14
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

Joined: Jan 31, 2000
Posts: 1467
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).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: editing records in database