java - How to run SQL TRANSACTION in a PreparedStatement -


i have sql transaction query unable run. can 1 tell me please why? have failed run using preparedstament.executequery(); well.

start transaction; select total_installment_remaining  payment_loan loan_id = 1 update; update payment_loan set total_installment_remaining =total_installment_remaining-1 loan_id = 1; commit; 

turn off autocommit, use connection.commit() end transaction.

connection.setautocommit(false); statement stmt = con2.createstatement();  // automatically start transaction resultset rs = stmt.executequery("select total_installment_remaining  payment_loan loan_id = 1 update");  // process result if needed ...  stmt.executeupdate("update payment_loan set total_installment_remaining =total_installment_remaining-1 loan_id = 1");  // end transaction , persist changes connection.commit(); 

if don't need result of select in code, don't need select ... update in first place, because update lock row anyway.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -