0

findFirstRow当我尝试使用 Jackcess 查找需要删除的行以删除表时,为什么无法光标?

private static void deleteTable(Database db, String tableName) throws IOException {
    Table table = db.getSystemTable(tableName);
    if (table == null) {
        return;
    }
    Cursor cursor = table.getDefaultCursor();
    Map<String, Object> criteria = new HashMap<String, Object>();
    criteria.put("Name", tableName);
    criteria.put("Type", (short) 1);
    if (cursor.findFirstRow(criteria)) {
        table.deleteRow(cursor.getCurrentRow());
        Log.e(TAG, "delete " + tableName + "   success!");
    } else {
        Log.e(TAG, "can't find this Table");//run here
    }
    db.flush();
    db.close();
}

ps:没有报告异常

4

1 回答 1

0

您的错误是您打开的是要删除的表,而不是保存数据库对象列表的系统表。代替

Table table = db.getSystemTable(tableName);

你需要使用

Table table = db.getSystemTable("MSysObjects");
于 2016-04-25T13:18:19.207 回答