Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Ok I found out the answer and here is the Code by using:
con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
and not
con.setAutoCommit(
false
);
Connection con = null; DataSource ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource"); con = ds.getConnection(); try{ if (!con.isClosed()){ con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); // Some code to select a Record for checking! // sql = "select * from tables for update"; ... if (checking == true) { result = true; } else { // Some code update another db record here! ... }; con.close(); } catch (Exception e) { LogUtil.error("Application",e, "Error updateing data"); } finally { if (con !=null) { con.close(); }; }
Dear Expert,
I would like to make a db transaction with the following code.
However, I get the error of "java.sql.SQLException: Auto-commit can not be set while enrolled in a transaction"
Everyone can point me how to solve this problem.
Many Thanks!
Best Regards
Tony Chu