SQLLite Exception at ALTER TABLE in DatabaseHelper.onUpgrade - using ORMLite

123 views
Skip to first unread message

pan...@englishdost.com

unread,
Dec 19, 2014, 5:08:48 AM12/19/14
to ormli...@googlegroups.com
Hi,

I am using ORMLite and recently upgraded my database to include a few columns in one of the tables. My DatabaseHelper.onUpgrade looks like this

public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) {

      if (oldVersion < 2) {
          try {
              getSentenceResponseDao().
executeRaw("ALTER TABLE 'SentenceResponse' ADD COLUMN (result INTEGER," +
                      " hint INTEGER,"+
                      " micEnabled INTEGER," +
                      " micPressed INTEGER" +
                      " speechCompleted INTEGER" +
                      " speechRecognitionResultArrived INTEGER" +
                      " connectionType INTEGER" +
                      " networkStrength INTEGER);");
          } catch (Exception e) {
              Crashlytics.logException(e);
          }
      }

One of my users got an exception while upgrading the app, which might be the issue for my future can any one help here. I have attached the stackTrace of Exception.

Non-fatal Exception: java.sql.SQLException
Could not run raw execute statement ALTER TABLE 'SentenceResponse' ADD COLUMN (result INTEGER, hint INTEGER, micEnabled INTEGER, micPressed INTEGER speechCompleted INTEGER speechRecognitionResultArrived INTEGER connectionType INTEGER networkStrength INTEGER);

com.j256.ormlite.misc.SqlExceptionUtil.create

com.j256.ormlite.dao.BaseDaoImpl.executeRaw

com.bluehat.englishdost2.db.DatabaseHelper.onUpgrade

com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.onUpgrade

android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:257)

android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:164)

com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection

com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection

com.j256.ormlite.stmt.StatementExecutor.buildIterator

com.j256.ormlite.stmt.StatementExecutor.query

com.j256.ormlite.dao.BaseDaoImpl.query

com.j256.ormlite.stmt.QueryBuilder.query

com.j256.ormlite.stmt.Where.query

com.bluehat.englishdost2.background.GetListOfConversationsInLayout.doInBackground

com.bluehat.englishdost2.background.GetListOfConversationsInLayout.doInBackground

android.os.AsyncTask$2.call (AsyncTask.java:288)

java.lang.Thread.run (Thread.java:841)
Caused by java.sql.SQLException

com.j256.ormlite.misc.SqlExceptionUtil.create

com.j256.ormlite.android.AndroidCompiledStatement.execSql

com.j256.ormlite.android.AndroidCompiledStatement.runExecute

com.j256.ormlite.stmt.StatementExecutor.executeRaw

com.j256.ormlite.dao.BaseDaoImpl.executeRaw

com.bluehat.englishdost2.db.DatabaseHelper.onUpgrade

com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.onUpgrade

android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:257)

android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:164)

com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection

com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection

com.j256.ormlite.stmt.StatementExecutor.buildIterator

com.j256.ormlite.stmt.StatementExecutor.query

com.j256.ormlite.dao.BaseDaoImpl.query

com.j256.ormlite.stmt.QueryBuilder.query

com.j256.ormlite.stmt.Where.query

com.bluehat.englishdost2.background.GetListOfConversationsInLayout.doInBackground

com.bluehat.englishdost2.background.GetListOfConversationsInLayout.doInBackground

android.os.AsyncTask$2.call (AsyncTask.java:288)

java.lang.Thread.run (Thread.java:841)
Caused by android.database.sqlite.SQLiteException

android.database.sqlite.SQLiteConnection.nativePrepareStatement (SQLiteConnection.java)

android.database.sqlite.SQLiteDatabase.execSQL (SQLiteDatabase.java:1787)

com.j256.ormlite.android.AndroidCompiledStatement.execSql

com.j256.ormlite.android.AndroidCompiledStatement.runExecute

com.j256.ormlite.stmt.StatementExecutor.executeRaw

com.j256.ormlite.dao.BaseDaoImpl.executeRaw

com.bluehat.englishdost2.db.DatabaseHelper.onUpgrade

com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.onUpgrade

android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:257)

android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:164)

com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection

com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection

com.j256.ormlite.stmt.StatementExecutor.buildIterator

com.j256.ormlite.stmt.StatementExecutor.query

com.j256.ormlite.dao.BaseDaoImpl.query

com.j256.ormlite.stmt.QueryBuilder.query

com.j256.ormlite.stmt.Where.query

com.bluehat.englishdost2.background.GetListOfConversationsInLayout.doInBackground

com.bluehat.englishdost2.background.GetListOfConversationsInLayout.doInBackground

android.os.AsyncTask$2.call (AsyncTask.java:288)

java.lang.Thread.run (Thread.java:841)


Thanks
Pankaj
Co-Founder, EnglishDost
B.Tech, Comp Sci & Engg,
IIT Madras, Class of 2008
9886259533
Reply all
Reply to author
Forward
0 new messages