krummas / DrizzleJDBC

A BSD licensed JDBC driver for Drizzle and MySQL
BSD 3-Clause "New" or "Revised" License
31 stars 22 forks source link

NPE when calling Statement.getUpdateCount() after Statement.execute() #30

Open StephG38 opened 9 years ago

StephG38 commented 9 years ago

According to javadoc, There are no more results when the following is true: ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))

The following code will throw a Null Pointer Exception : boolean isRS= stmt.execute(sql); int updateCount = -1; while (isRS || (updateCount = stmt.getUpdateCount()) > -1) { if (isRS) { ResultSet rs = null; try { rs = stmt.getResultSet(); // Process resultset } finally { if (rs != null) { rs.close(); rs = null; } } } else { // an update count System.out.println("Result is " + stmt.getUpdateCount()); } isRS = stmt.getMoreResults(); }

Error message is : java.lang.NullPointerException at org.drizzle.jdbc.DrizzleStatement.getUpdateCount(DrizzleStatement.java:740)