Android 安卓&;OrmLite:OnUpgrade失败

Android 安卓&;OrmLite:OnUpgrade失败,android,ormlite,Android,Ormlite,我对Android上的OrmLite有一个小问题 当我增加数据库版本时,onUpgrade方法按预期在我的OrmLite助手中调用。升级后,调用onCreate方法,我得到以下异常: 11-24 10:09:45.720: ERROR/AndroidConnectionSource(390): connection saved com.j256.ormlite.android.AndroidDatabaseConnection@44f0f478 is not the one be

我对Android上的OrmLite有一个小问题

当我增加数据库版本时,
onUpgrade
方法按预期在我的OrmLite助手中调用。升级后,调用
onCreate
方法,我得到以下异常:

11-24 10:09:45.720: ERROR/AndroidConnectionSource(390): connection saved
    com.j256.ormlite.android.AndroidDatabaseConnection@44f0f478 is not the one
    being cleared com.j256.ormlite.android.AndroidDatabaseConnection@44f5d310
我不知道为什么清除的连接与保存的连接不同

我还将数据库函数(insert…)放入了OrmLite助手类中。也许这是个问题

我的助手类中的一个片段:

public class OrmLiteDBProvider extends OrmLiteSqliteOpenHelper
    implements IEntityProvider, IDBProvider {

//snip
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
    try {
        Log.i(OrmLiteDBProvider.class.getName(), "Creating database and tables");
        TableUtils.createTable(connectionSource, OrgManaged.class);
    } catch (SQLException e) {
        Log.e(OrmLiteDBProvider.class.getName(),
            "Can't create database and tables", e);
        throw new RuntimeException(e);
    }
}
@Override
public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource,
   int oldVersion, int newVersion) {
    try {
        Log.i(OrmLiteDBProvider.class.getName(),
            "Database version changed. Dropping database.");
        TableUtils.dropTable(connectionSource, OrgManaged.class, true);
        // after we drop the old databases, we create the new ones
        onCreate(db);
    } catch (SQLException e) {
        Log.e(OrmLiteDBProvider.class.getName(), "Can't drop databases", e);
        throw new RuntimeException(e);
    }
}
我想我错过了一些简单的东西


提前感谢您的努力。

好的,我看到了问题,不幸的是,它也存在于示例程序中。在helper类中,
onUpgrade
方法应使用:

onCreate(db, connectionSource);
而不是调用子类的以下命令:

onCreate(db);

我在已修复的
HelloAndroid
示例程序中重现了这个问题。我还在ORMLite代码Android端的
OrmLiteSqliteOpenHelper
基类中正确地修复了这个问题。很抱歉出现这个问题。

我忘了提到:它是OrmLite 4.5版,您可以发布整个异常堆栈SAXS吗?谢谢。酷,这解决了我的问题。非常感谢您的快速响应和您的努力。我真的很感激你的工作,继续。