[CONJ-62] NullPointerException when executeBatch is called, and batch list is empty Created: 2013-09-09  Updated: 2013-10-02  Resolved: 2013-09-09

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1.4

Type: Bug Priority: Major
Reporter: Vladislav Vaintroub Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None


 Description   

This simple part of code demonstrates the NullPointerException in the current code of the MariaDB driver (v1.1.3):

try {
Class.forName("org.mariadb.jdbc.Driver");
String dbUrl = "jdbc:mysql://host:3306/db";
Connection con = DriverManager.getConnection(dbUrl, "user", "pwd");
Statement stmt = con.createStatement();
// do not add any batch entries!
stmt.executeBatch(); // -> NullPointerException
con.close();
}
catch(Exception ex) {
ex.printStackTrace();
}
 

Result:
java.lang.NullPointerException
at org.mariadb.jdbc.MySQLStatement.executeBatch(MySQLStatement.java:1121)

This NullPointerException is raised when the executeBatch is called with no batches added.



 Comments   
Comment by Lance Man [ 2013-10-02 ]

We encountered the same issue for the PreparedStatement/CallableStatement cases. In the MySQLPreparedStatement.class, it overrides the executeBatch() of MySQLStatement.class but no super() was called. NPE was thrown based on the same situation. Do you consider to fix it as well?

Generated at Thu Feb 08 03:12:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.