Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJ-261] add tests
  • Loading branch information
rusher committed Apr 28, 2016
1 parent 1f256c1 commit 58f90dc
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/java/org/mariadb/jdbc/MultiTest.java
Expand Up @@ -807,4 +807,50 @@ private void continueOnBatchError(boolean continueBatch, int waitedResult, boole
}
}

@Test
public void testCloseStatementWithoutQuery() throws SQLException {
final Statement statement = sharedConnection.createStatement();
// Make sure it is a streaming statement:
statement.setFetchSize(Integer.MIN_VALUE);
for (int count = 1; count <= 10; count++) {
statement.close();
}
}

@Test
public void testClosePrepareStatementWithoutQuery() throws SQLException {
final PreparedStatement preparedStatement = sharedConnection.prepareStatement("SELECT 1");
// Make sure it is a streaming statement:
preparedStatement.setFetchSize(Integer.MIN_VALUE);
for (int count = 1; count <= 10; count++) {
preparedStatement.close();
}
}

@Test
public void testCloseStatement() throws SQLException {
createTable("testStatementClose", "id int");
final Statement statement = sharedConnection.createStatement();
// Make sure it is a streaming statement:
statement.setFetchSize(1);

statement.execute("INSERT INTO testStatementClose (id) VALUES (1)");
for (int count = 1; count <= 10; count++) {
statement.close();
}
}

@Test
public void testClosePrepareStatement() throws SQLException {
createTable("testPrepareStatementClose", "id int");
sharedConnection.createStatement().execute("INSERT INTO testPrepareStatementClose(id) VALUES (1),(2),(3)");
final PreparedStatement preparedStatement = sharedConnection.prepareStatement("SELECT * FROM testPrepareStatementClose");
preparedStatement.execute();
// Make sure it is a streaming statement:
preparedStatement.setFetchSize(1);

for (int count = 1; count <= 10; count++) {
preparedStatement.close();
}
}
}

0 comments on commit 58f90dc

Please sign in to comment.