![](/img/trans.png)
[英]Does anyone know what this exception is regarding firebase performance monitoring?
[英]Does anyone know what a Invalid tables exception is?
我正在努力完善我之前為我的應用程序編寫的數據庫。 以前的數據庫運行良好,但混亂不堪,我做了愚蠢的事情,嘗試清理它。 這導致了我無法開始破譯的奇怪而有用的錯誤。 據我所知,經過大量回溯跟蹤並最終返回並具有與以前的數據庫相同的數據庫外觀之后,我仍然遇到了被詛咒的錯誤。
錯誤:
03-02 10:38:30.205: ERROR/AndroidRuntime(505): FATAL EXCEPTION: JobLister: RunThread jobs
03-02 10:38:30.205: ERROR/AndroidRuntime(505): java.lang.IllegalStateException: Invalid tables
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at android.database.sqlite.SQLiteDatabase.findEditTable(SQLiteDatabase.java:1313)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1414)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1370)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1450)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at com.android.appion.arm.database.Database.getRecord(Database.java:120)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at com.android.appion.arm.database.Database.getRecord(Database.java:107)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at com.android.appion.arm.database.Database.getRecord(Database.java:97)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at com.android.appion.arm.activities.JobLister.getJobs(JobLister.java:69)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at com.android.appion.arm.activities.JobLister.access$3(JobLister.java:66)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at com.android.appion.arm.activities.JobLister$2.run(JobLister.java:52)
03-02 10:38:30.205: ERROR/AndroidRuntime(505): at java.lang.Thread.run(Thread.java:1020)
因此,自然而然地我遵循了鋸痕,並發現它源自我在一項活動中對自然保存在服務中的數據庫的調用。
來自活動的數據庫調用:
Cursor c = mService.getDatabase().getRecord(new Table.Jobs());
這一切似乎都是正確的。 使用該服務,我獲取數據庫,並使用數據庫獲取Table作業中的所有記錄。
getRecord方法stepper和Jobs表定義:
public Cursor getRecord(DataTable table) {
return getRecord(table, null);
}
public Cursor getRecord(DataTable table, String[] columns) {
return getRecord(table, columns, null);
}
/**
* Return a Cursor with every item in which data is only coming from columns,
* and the records satisfies all selection requirements.
* @param table The table to query.
* @param columns The columns to retieve data.
* @param selection The requirements to base the data collection on. (WHERE statement
* without WHERE).
* @return The Cursor full of queried items.
*/
public Cursor getRecord(DataTable table, String[] columns, String selection) {
return mDB.query(table.TITLE, (columns == null) ? new String[] {"*"} : columns,
selection, null, null, null, null);
}
和表:
public static class Jobs extends DataTable {
public static final String TITLE = "jobs";
public static final String[] FIELD = {"job_id",
"job_name", // User given name
"job_contact", // client
"job_location", // The location of the job
"job_notes",
"job_summary", // The byte object of a JobSummary
"wkb_name", // the workbench that is being used for the job
"job_startdate",
"job_enddate"};
public Jobs() { super(); }
public String getTable() {
return "create table " + TITLE +
"(" + FIELD[0] + " integer primary key autoincrement, " +
FIELD[1] + " text, " +
FIELD[2] + " blob, " +
FIELD[3] + " blob, " +
FIELD[4] + " text, " +
FIELD[5] + " blob, " +
FIELD[6] + " blob, " +
FIELD[7] + " text, " +
FIELD[8] + " text " +
");";
}
}
現在,這種設計風格可以完美地與我的上一個數據庫配合使用,並且一字不漏,再減去一個事實,即Jobs表擴展了DataTable,以簡化由於抽象而導致的初始數據庫創建。
誰能看到這有什么問題嗎?
編輯::
我閱讀了錯誤的源代碼( SQLiteDatabase.findEditTable()
),似乎問題在於表中沒有數據。 如果是這種情況,我應該得到一個空的Cursor返回值,不是嗎? 還是我誤解了我正在閱讀的內容,它實際上表明找不到表?
好的,我發現了問題所在。 無效表異常隱藏了一個錯誤,指出數據庫已正確創建。 我的壞:P
編輯::這是一個抽象問題。 由於我是從DataTables擴展而來的,所以它是靜態調用的,因此從未正確初始化過。 課程:不要對表使用抽象類。 除了很難看之外,它也不起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.