确认数据库配置是否正确,例如:
let context = getContext(this)
const STORE_CONFIG :relationalStore.StoreConfig= {
name: name, // 数据库文件名
securityLevel: relationalStore.SecurityLevel.S4, // 数据库安全级别
encrypt: false, // 可选参数,指定数据库是否加密,默认不加密
};
relationalStore.getRdbStore(context, STORE_CONFIG, (err, store) => {
if (err) {
console.error(Failed to get RdbStore. Code:${err.code}, message:${err.message});
return;
}
console.info('Succeeded in getting RdbStore.');
let predicates = new relationalStore.RdbPredicates('SYS_DICT')
let names = Array<string>()
if (store!= undefined) {
store.query(predicates, [], (error: BusinessError, resultSet) => {
if (error) {
console.error(Failed to get RdbStore. Code:${error.code}, message:${error.message});
return;
}