# SQLiteException happens onUpgrade

**URL:** <https://discuss.zetetic.net/t/sqliteexception-happens-onupgrade/3155>\
**Category:** SQLCipher\
**Created:** [October 11, 2018, 1:05pm UTC](https://discuss.zetetic.net/t/sqliteexception-happens-onupgrade/3155 "2018-10-11T13:05:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iskugor](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/iskugor/32/856_2.png) [@iskugor](https://discuss.zetetic.net/u/iskugor)\
**Post date:** [October 11, 2018, 1:05pm UTC](https://discuss.zetetic.net/t/sqliteexception-happens-onupgrade/3155/1 "2018-10-11T13:05:58Z")

</div>

Hello.

In Google Play console I regularly see “SQLiteException” after I database scheme changes (according to some reports, same error happens when Android OS updates).

> Caused by: net.sqlcipher.database.SQLiteException:  
> at net.sqlcipher.database.SQLiteDatabase.native\_execSQL (SQLiteDatabase.java)  
> at net.sqlcipher.database.SQLiteDatabase.execSQL (SQLiteDatabase.java:2265)  
> at de.greenrobot.dao.database.EncryptedDatabase.execSQL (EncryptedDatabase.java:36)  
> at com.teamwire.db.Database$1.onUpgrade (Database.java:73)  
> at de.greenrobot.dao.database.EncryptedDatabaseOpenHelper$Adapter.onUpgrade (EncryptedDatabaseOpenHelper.java:84)  
> at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:173)  
> at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:129)  
> at de.greenrobot.dao.database.EncryptedDatabaseOpenHelper.getWritableDatabase (EncryptedDatabaseOpenHelper.java:49)

I can’t reproduce it, SQL statements in “onUpgrade” function work fine for me. Any idea why it happens and how could I prevent it?

I’m using latest sqlcipher version - 3.5.9.

Thanks!

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [October 11, 2018, 1:32pm UTC](https://discuss.zetetic.net/t/sqliteexception-happens-onupgrade/3155/2 "2018-10-11T13:32:25Z")

</div>

Hello @iskugor

It is difficult to say without additional information. The JNI call to `native_execSQL` will throw an exception with a few states [during execution](https://github.com/sqlcipher/android-database-sqlcipher/blob/master/android-database-sqlcipher/src/main/cpp/net_sqlcipher_database_SQLiteDatabase.cpp#L326-L374) in which we provide a message to the exception with further details. It would be best to narrow down the scenario and see if you can capture the exception output to further understand the cause.
