xerial / sqlite-jdbc

SQLite JDBC Driver
Apache License 2.0
2.86k stars 619 forks source link

NullPointerException by getUpdateCount() #1129

Closed wise-coders closed 3 months ago

wise-coders commented 5 months ago

I execute different statements using boolean ret = statement.execute(query); I cannot know ahead which is the query. Next I call: if ( !ret ) cnt = statement.getUpdateCount()

This shouldn't trigger any exception. The documentation says: Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned. This method should be called only once per result.

java.lang.NullPointerException: Cannot invoke "org.sqlite.core.SafeStmtPtr.isClosed()" because "this.pointer" is null at org.sqlite.jdbc3.JDBC3Statement.getLargeUpdateCount(JDBC3Statement.java:199) at org.sqlite.jdbc3.JDBC3Statement.getUpdateCount(JDBC3Statement.java:188) at com.wisecoders.dbs.dbms.connect.model.envoy.GeneralToResultStatement.execute(GeneralToResultStatement.java:72) at com.wisecoders.dbs.dbms.connect.model.envoy.Envoy.execute(Envoy.java:392) at com.wisecoders.dbs.data.fx.FxAbstractSqlEditor$1.call(FxAbstractSqlEditor.java:125) at com.wisecoders.dbs.data.fx.FxAbstractSqlEditor$1.call(FxAbstractSqlEditor.java:117)

gotson commented 3 months ago

are you able to provide a reproduction test case?

wise-coders commented 3 months ago

It is my mistake, I didn't save the statement I executed and now I cannot reproduce it anymore. I close the issue for now.