File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "editing records in database" Watch "editing records in database" New topic

editing records in database

mike sutton

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.");
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
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

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
I give you an example which I used in my web application. Please take a look. This updates the Employe's whose ID=knownID

maha anna
[This message has been edited by maha anna (edited December 28, 2000).]
I agree. Here's the link:
subject: editing records in database
It's not a secret anymore!