xtern commented on code in PR #1880: URL: https://github.com/apache/ignite-3/pull/1880#discussion_r1169867823
########## modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcTransactionTest.java: ########## @@ -0,0 +1,307 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.jdbc; + +import static org.hamcrest.Matchers.containsString; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +/** + * Verifies that SQL DML statements can use an explicit transaction using the jdbc API. + */ +public class ItJdbcTransactionTest extends AbstractJdbcSelfTest { + /** Insert query. */ + private static final String SQL_INSERT = "insert into TEST values (%d, '%s')"; + + /** Insert query for a prepared statement. */ + private static final String SQL_INSERT_PREPARED = "insert into TEST values (?, ?)"; + + @BeforeAll + public static void beforeClass() throws Exception { + try (Statement statement = conn.createStatement()) { + statement.executeUpdate("create table TEST(ID int primary key, NAME varchar(20));"); + } + } + + @AfterEach + public void afterEach() throws Exception { + try (Statement statement = conn.createStatement()) { + statement.executeUpdate("delete from TEST;"); + } + + conn.setAutoCommit(true); + } + + /** + * Tests {@link Connection#setAutoCommit(boolean)} and {@link Connection#getAutoCommit()} methods behaviour. + * <ul> + * <li>Auto-commit mode is enabled by default. + * <li>If {@code setAutoCommit} is called and the auto-commit mode is not changed, the call is a no-op. + * <li>If {@code setAutoCommit} is called during transaction and auto-commit mode changed then active transaction is committed. + * <li>Call to {@code setAutoCommit} or {@code getAutoCommit} on a closed connection throws exception. + * </ul> + * + * @throws SQLException If failed. + */ + @Test + public void testAutoCommitModeChange() throws SQLException { + try (Connection conn = DriverManager.getConnection(URL)) { + assertTrue(conn.getAutoCommit()); + conn.setAutoCommit(true); Review Comment: We just check that there were no exceptions. Maybe it's redundant. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org