AMashenkov commented on code in PR #6772:
URL: https://github.com/apache/ignite-3/pull/6772#discussion_r2431837208
##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection2.java:
##########
@@ -247,14 +261,51 @@ public String nativeSQL(String sql) throws SQLException {
return sql;
}
+ @Nullable Transaction startTransactionIfNoAutoCommit() {
+ if (transaction == null && !autoCommit) {
+ transaction = igniteClient.transactions().begin(new
TransactionOptions().readOnly(false));
+ return transaction;
+ } else {
+ return transaction;
+ }
+ }
+
+ private void finishTx(boolean commit) throws SQLException {
+ try {
+ Transaction tx = this.transaction;
+ if (tx == null) {
+ return;
+ }
+ // Null out the transaction first.
+ this.transaction = null;
+
+ if (commit) {
+ tx.commit();
+ } else {
+ tx.rollback();
+ }
+ } catch (Exception e) {
+ String error = "The transaction " + (commit ? "commit" :
"rollback") + " request failed.";
Review Comment:
```suggestion
String error = IgniteStringUtils.format("The transaction {}
request failed.", commit ? "commit" : "rollback") ;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]