Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[CONJ-1071] Error during Bulk execution might result in connection wr…
…ong state
- Loading branch information
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
src/test/java/org/mariadb/jdbc/integration/BulkStmtSplitError.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package org.mariadb.jdbc.integration; | ||
|
|
||
| import java.sql.PreparedStatement; | ||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
| import java.sql.Types; | ||
| import org.junit.jupiter.api.*; | ||
| import org.mariadb.jdbc.Statement; | ||
|
|
||
| public class BulkStmtSplitError extends Common { | ||
|
|
||
| @AfterAll | ||
| public static void drop() throws SQLException { | ||
| Statement stmt = sharedConn.createStatement(); | ||
| stmt.execute("DROP TABLE IF EXISTS BulkStmtSplitError"); | ||
| } | ||
|
|
||
| @BeforeAll | ||
| public static void beforeAll2() throws SQLException { | ||
| drop(); | ||
| Statement stmt = sharedConn.createStatement(); | ||
| stmt.execute( | ||
| "CREATE TABLE BulkStmtSplitError (t1 int not null primary key, field varchar(300))"); | ||
| stmt.execute("FLUSH TABLES"); | ||
| } | ||
|
|
||
| @Test | ||
| public void BulkStmtSplitError() throws SQLException { | ||
| Statement stmt = sharedConn.createStatement(); | ||
| stmt.execute("INSERT INTO BulkStmtSplitError VALUES (1, 'tt'), (2, 'tt2')"); | ||
|
|
||
| try (PreparedStatement prep = | ||
| sharedConn.prepareStatement("insert into BulkStmtSplitError values (?, ?)")) { | ||
| prep.setInt(1, 1); | ||
| prep.setNull(2, Types.VARCHAR); | ||
| prep.addBatch(); | ||
| prep.setInt(1, 2); | ||
| prep.setString(2, "Kenny"); | ||
| prep.addBatch(); | ||
| prep.executeBatch(); | ||
| } catch (SQLException e) { | ||
| // eat | ||
| } | ||
|
|
||
| ResultSet rs = stmt.executeQuery("SELECT count(*) FROM agent"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
RadekWikturna
|
||
| Assertions.assertTrue(rs.next()); | ||
| Assertions.assertEquals(2, rs.getInt(1)); | ||
| } | ||
| } | ||
This is table likely does not exist in this test case - I wonder how this can work!
I provided this table in my example code.