diff --git a/data/ORM/entry/src/main/java/ohos/samples/orm/slice/OrmContextSlice.java b/data/ORM/entry/src/main/java/ohos/samples/orm/slice/OrmContextSlice.java index e77bff3946946ae39a17c6b564b7f00b3e4bf6ff..ceb972ae3fa49fbc559a45250cb9f1d1ab312d74 100644 --- a/data/ORM/entry/src/main/java/ohos/samples/orm/slice/OrmContextSlice.java +++ b/data/ORM/entry/src/main/java/ohos/samples/orm/slice/OrmContextSlice.java @@ -26,6 +26,7 @@ import ohos.data.orm.OrmMigration; import ohos.data.orm.OrmObjectObserver; import ohos.data.orm.OrmPredicates; import ohos.data.preferences.Preferences; +import ohos.data.rdb.RdbException; import ohos.data.rdb.RdbStore; import ohos.hiviewdfx.HiLog; import ohos.hiviewdfx.HiLogLabel; @@ -267,8 +268,13 @@ public class OrmContextSlice extends AbilitySlice { @Override public void onMigrate(RdbStore store) { - HiLog.info(LABEL_LOG, "DataBase Version 1->2 onMigrate called"); - store.executeSql("ALTER TABLE `Book` ADD COLUMN `addColumn12` INTEGER"); + try { + HiLog.info(LABEL_LOG, "DataBase Version 1->2 onMigrate called"); + store.executeSql("ALTER TABLE `Book` ADD COLUMN `addColumn12` INTEGER"); + } + catch (RdbException e) { + HiLog.error(LABEL_LOG, "TestOrmMigration12.onMigrate exception, %{public}s", e.getMessage()); + } } }