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

Exception during finalize of Statement/PreparedStatement #336

Closed
b3nn0 opened this issue May 1, 2018 · 0 comments
Closed

Exception during finalize of Statement/PreparedStatement #336

b3nn0 opened this issue May 1, 2018 · 0 comments

Comments

@b3nn0
Copy link
Contributor

b3nn0 commented May 1, 2018

Hi,
I have code that basically does this:

  • Open DB Connection
  • Create prepared statements and use them
  • Close prepared statements
  • Close DB Connection

However, I'm always getting exceptions when the next GC run occurs:

org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (Connection is closed)

The reason seems to be quite simple: Finalize of the prepared statements calls close(), which in turn calls CoreStatement.internalClose().
Internalclose will then check if the DB is already closed, and then throw the exception.

The simplest (and IMO cleanest) solution would just be to switch these two checks in CoreStatement.java, method internalClose():

if (db.conn.isClosed())
            throw DB.newSQLException(SQLITE_ERROR, "Connection is closed");

if (pointer == 0)
            return;
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