Skip to content

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

@StephG38

Description

@StephG38

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions