understanding Java JDBC error

后端 未结 4 1690
野性不改
野性不改 2021-01-28 16:29

I was hoping to have some assistance in understanding this error. I am making a simple connection to a database, and for some reason it doesn\'t like my input, but I am failing

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-28 16:46

    The problem comes from the makeDeposit() method, specifically from these lines:

    String sql = "insert into MYTABLE_TRANSACTIONS (ACCOUNT_ID,TRANSACTION_TYPE,AMOUNT) values (name, action, amount)";
    stmt.executeUpdate(sql);
    

    Those values aren't right, you probably want some variable named name, not the actual string name.

    To provide a bit more insight, the error is a list of the methods that were ran until the error occurred. The one at the top is the most recent. So everything starts from the main() method, which runs the makeDeposit() method and then some methods that follow the call of stmt.executeUpdated(sql). Hope that clears it up.

提交回复
热议问题