Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StephG38 opened this issue Sep 22, 2014 · 0 comments
Open

Comments

@StephG38
Copy link
Contributor

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)

StephG38 pushed a commit to StephG38/DrizzleJDBC that referenced this issue Sep 22, 2014
krummas added a commit that referenced this issue Sep 23, 2014
Fixes issue #30. No more NPE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant