2017-03-22 4 views
0

を作成し、私を助けてください、私はここに私のアプリの利用アイデアSQLiteException:「ヌル」に近い:構文エラー(コード1):、コンパイル中:テーブル

を実行したときに、私はこのエラーを取得エラー

の画面ですここ

http://prntscr.com/en3lcu

)私は私の頭を壊すので、私は、私を助けてくださいテーブル

private String getTableDDL(final Class<? extends GlassContract.Table> table) { 
    return getTableDDL(table, GlassContract.getTableName(table)); 
} 

private String getTableDDL(final Class<? extends GlassContract.Table> table, String tableName) { 
    final StringBuilder sql = new StringBuilder(128); 
    sql.append("create table ").append(tableName).append(" ("); 
    for (final Field field : table.getFields()) { 
     if (field.getName().startsWith("_") || field.isAnnotationPresent(Deprecated.class)) 
      continue; 
     try { 
      sql.append(field.get(null)); 
     } catch (Exception ignore) { 
     } 
     try { 
      final Field type = table.getDeclaredField("_SQL_" + field.getName() + "_TYPE"); 
      sql.append(' ').append(type.get(null)); 
     } catch (Exception ignore) { 
      sql.append(" TEXT"); 
     } 
     sql.append(','); 
    } 

    try { 
     final Field type = table.getDeclaredField("_PK_COMPOSITE"); 
     sql.append("PRIMARY KEY(").append(type.get(null)).append(")"); 
     sql.append(','); 
    } catch (Exception ignore) { 
     // ignore 
    } 
    try { 
     final Field type = table.getDeclaredField("_UNIQUE_COMPOSITE"); 
     sql.append("UNIQUE(").append(type.get(null)).append(")"); 
     sql.append(','); 
    } catch (Exception ignore) { 
     // ignore 
    } 

    sql.setLength(sql.length() - 1); // chop off last comma 

    sql.append(')'); 
    Log.v(TAG, "DDL for " + table.getSimpleName() + ": " + sql); 
    return sql.toString(); 
} 

を作成するコードの一部です)

+1

と呼ばれる2つの同じ名前のフィールドを作成している場合であっても

質問の体内でのエラーメッセージを投稿してください。 – Compass

+0

'getTableDDL()'は実際に何を返しますか? –

+0

予約されたキーワード「NULL」は使用できません。 –

答えて

0

実際にnullという名前のテーブルにテキストフィールドを作成しようとしていますか?これは(と私はそれがないことを確認していない)動作しますが、あなたはこれを複製し、null

0

CREATE TABLEステートメントの最初のフィールドには、適切な名前(「null」)がありません。それが爆破する理由です。

不正な名前のフィールドもあります。

関連する問題