SQLLiteExcpetion at ALTER TABLE in DatabaseHelper.onUpgrade-using ORMLite

370 views
Skip to first unread message

pan...@englishdost.com

unread,
Dec 19, 2014, 5:07:51 AM12/19/14
to ormlit...@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

anton.ver...@gmail.com

unread,
Dec 20, 2014, 2:01:24 AM12/20/14
to ormlit...@googlegroups.com
At least what I can see is that you missed separating commas.

Kind regards,
Anton

Pankaj Chand

unread,
Dec 20, 2014, 2:32:27 AM12/20/14
to ormlit...@googlegroups.com
Thanks Anton,

It is embarrassing here, to miss such silly mistakes.

Regards
Pankaj

Pankaj
Co-Founder, EnglishDost
B.Tech, Comp Sci & Engg,
IIT Madras, Class of 2008
9886259533

--
You received this message because you are subscribed to a topic in the Google Groups "ORMLite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ormlite-user/YWQPPrmC4go/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ormlite-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages