GeeCON Prague 2014*
The moose likes JDBC and the fly likes whts wrong in this statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "whts wrong in this statement?" Watch "whts wrong in this statement?" New topic
Author

whts wrong in this statement?

Keshini Weerasuriya
Greenhorn

Joined: Jan 08, 2006
Posts: 24
Hi.. I'm trying to save changes and update the record. But this doesn't seem to work. Can anyone help?

st.executeUpdate("UPDATE Client " +
"SET (CliId = '"+id+"', Surname = '"+surname+"', FirstName = '"+firstname+"', Title = '"+Gen+"',NICNo = '"+NIC+"' , Image = '"+image+"',Address = '"+Address+"', TelNo = '"+no+"',Email = '"+mail+"')");
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

  • Is there any exception ?
  • Are you issuing a commit, after your update operation.
  • Just a suggestion, use PreparedStatement.



  • Shailesh


    Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
    Martin Simons
    Ranch Hand

    Joined: Mar 02, 2006
    Posts: 196
    Well, for one, you don't need parens around the set fields, also a couple
    of your field names have "No" in the name, which I assume means number.
    You are adding these fields as if they are strings, so check that those
    fields are actually character and not number types in the database, and
    last, but definately not least, there is no where clause in this update
    statement. Do you really wish to update every row in the table with this
    information or did you want to only update a specific row?
    Keshini Weerasuriya
    Greenhorn

    Joined: Jan 08, 2006
    Posts: 24
    No exceptions.. But the new data doesn't get updated
    Shailesh Chandra
    Ranch Hand

    Joined: Aug 13, 2004
    Posts: 1081

    put the complete method

    Shailesh
    Keshini Weerasuriya
    Greenhorn

    Joined: Jan 08, 2006
    Posts: 24
    I changed the statement to

    String query = "UPDATE Client SET (CliId = '"+id+"', Surname = '"+surname+"', FirstName = '"+firstname+"', Title = '"+Gen+"',NICNo = '"+NIC+"' , Image = '"+image+"',Address = '"+Address+"', TelNo = '"+no+"',Email = '"+mail+"') WHERE CliId = '" +id+ "'";

    st.executeUpdate(query);

    Now it says
    java.sql.SQLException: ORA-00907: missing right parenthesis
    Martin Simons
    Ranch Hand

    Joined: Mar 02, 2006
    Posts: 196
    I would say remove the parens around the set fields.
    Keshini Weerasuriya
    Greenhorn

    Joined: Jan 08, 2006
    Posts: 24
    Thanks Martin.. That worked.. :-)
     
    GeeCON Prague 2014
     
    subject: whts wrong in this statement?