java - How to decrease a column by some variable amount? -


i trying decrease value of column amount. in other words, column of type double , want decrease "total" amount. if initial value 100, has 100-total. here code:

preparedstatement checkdb1 = (preparedstatement) con.preparestatement("update accounts set balance=balance-? iban=?"); checkdb1.setstring(1, total); 

this gives syntax error saying:

 reason: actual argument double cannot converted string method invocation conversion 

so how can write query? thanks

the error type being used set preparedstatement parameter incorrect indicated error message

preparedstatement checkdb1 =         con.preparestatement("update accounts set balance=balance - ? iban=?"); checkdb1.setdouble(1, total);             ^^^ 

notice preparedstatement cast has been removed unnecessary


Comments