When CREATE statements are executed through executeBatch(), the subsequent call to getUpdateCount() returns -1, which is inconsistent with the behavior observed when executing CREATE statements using the execute() method, where getUpdateCount() returns 0. This behavior is also inconsistent with the MySQL Connector/J, which returns 0 in both scenarios.
@Test
|
public void test() throws SQLException {
|
Connection con = null;
|
Statement stmt = null;
|
con = DriverManager.getConnection("jdbc:mariadb://localhost:3366/test5?user=user&password=password");
|
stmt = con.createStatement();
|
stmt.addBatch("CREATE TABLE table211_0(id VARCHAR(5) PRIMARY KEY,value BOOL);");
|
stmt.addBatch("CREATE TABLE table211_0(id TINYINT PRIMARY KEY,value SMALLINT);");
|
try {
|
stmt.executeBatch();
|
} catch (Exception e) {
|
System.out.println(e);
|
}
|
System.out.println(stmt.getUpdateCount()); // -1
|
}
|