Created
February 27, 2020 14:15
-
-
Save vietj/8fdec4f5db6626668c9c3533d4f1fa41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JDBCTxOp extends AbstractJDBCAction<Void> { | |
private final TxCommand op; | |
public JDBCTxOp(JDBCStatementHelper helper, TxCommand op, SQLOptions options) { | |
super(helper, options); | |
this.op = op; | |
} | |
@Override | |
public Void execute(Connection conn) throws SQLException { | |
if (op == TxCommand.BEGIN) { | |
conn.setAutoCommit(false); | |
} else { | |
try { | |
if (op == TxCommand.COMMIT) { | |
conn.commit(); | |
} else { | |
conn.rollback(); | |
} | |
} finally { | |
conn.setAutoCommit(false); | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment