understanding Java JDBC error

后端 未结 4 1696
野性不改
野性不改 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

    String sql = "insert into MYTABLE_TRANSACTIONS (ACCOUNT_ID,TRANSACTION_TYPE,AMOUNT) values ('" + name + "', '" + action + "', " + amount + ")";
    

    You need the single quotes for the name and action columns since they are of type varchar, and also you need the actual values so you need to build your query with '+' sign.

    /Nick

提交回复
热议问题