Re: Update statements.



morc wrote:
hey im having a little bit of trouble excecuting my update statsments.
I chekd in access directly and am sure that there is no errors in my
SQL.

this is the code i used. The connection is fine its been tested before.


String remove = "UPDATE items SET qty = qty - 1 WHERE store =
'"+from+"' and barcode ='"+barcode+"'";

Statement stmt = null;

try {
stmt = conn01.createStatement();
stmt.executeUpdate(remove);
} catch (SQLException e) {
e.printStackTrace();
}


It would be helpful if you could tell us

(a) what type of database server your program is talking to? Is it Oracle? Is it MySQL? Or is it something else? What?

(b) what the stack trace looks like.

You might also want to consider using a prepared statement, in order to avoid putting quotes directly into the query string.

David Harper
Cambridge, England
.



Relevant Pages

  • Re: Excecuting Update Statements
    ... I chekd in access directly and am sure that there is no errors in my ... The connection is fine its been tested before. ... you're leaving yourself vulnerable to SQL injection attacks. ... Oliver ...
    (comp.lang.java.programmer)
  • Cant retreive Date it gives me the same exception
    ... SQLException with error number -1205. ... Connection connectthrows SQLException { ... public void createDBProperthrows SQLException ... Statement stmt = connection.createStatement; ...
    (comp.databases.informix)
  • Re: trouble connecting to mysql
    ... Statement stmt = con.createStatement; ... Connection conn=DriverManager.getConnection; ... now i must be making a mistake somewhere since the browser shows this: ... Unexpected end of input stream ...
    (comp.lang.java.databases)
  • Re: approaches for embedding a data language in a general purpose language
    ... #sql {INSERT ... Statement stmt = conn.createStatement; ... VALUES ('999999999', 'Doug Barry')"); ... advantage of embedded SQL would be in the integration of ...
    (comp.databases.theory)
  • Update statements.
    ... hey im having a little bit of trouble excecuting my update statsments. ... I chekd in access directly and am sure that there is no errors in my ... Statement stmt = null; ...
    (comp.lang.java.databases)