Java E/SQLiteLog:(1)没有这样的列:100

Java E/SQLiteLog:(1)没有这样的列:100,java,android,sqlite,csv,Java,Android,Sqlite,Csv,我花了很长时间来解决这个问题,但无法解决它。 我确信没有错误的代码,但是如果我执行emulator,那么问题是当我单击listview上的特定项目时,它会显示“再次打开应用程序”。我制作了一个数据库,并将csv文件中的数据放入其中。代码如下: word_db.csv DB_Word.java } 类别\u wordview1.java public class Categories\u wordview 1扩展了AppCompative活动{ 阵列适配器; 列表视图词表; 单词dbc; sql

我花了很长时间来解决这个问题,但无法解决它。 我确信没有错误的代码,但是如果我执行emulator,那么问题是当我单击listview上的特定项目时,它会显示“再次打开应用程序”。我制作了一个数据库,并将csv文件中的数据放入其中。代码如下:

word_db.csv

DB_Word.java

}

类别\u wordview1.java

public class Categories\u wordview 1扩展了AppCompative活动{
阵列适配器;
列表视图词表;
单词dbc;
sqlitedb数据库;
字符串sql;
光标;
字符串[]结果;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u category\u wv);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
wordlist=(ListView)findViewById(R.id.wordlist);
dbc=新的DB_字(本);
删除();
insertAll();
选择();
}
公共作废删除(){
试一试{
System.out.println(“删除完成”);
db=dbc.getWritableDatabase();
db.execSQL(“从word中删除;”);
}捕获(例外e){
e、 printStackTrace();
}
}
公共作废选择(){
System.out.println(“选择”);
试一试{
System.out.println(“选择尝试”);
db=dbc.getReadableDatabase();
sql=“从word中选择word_kor、word_eng、word_pro;”;
cursor=db.rawQuery(sql,null);
int count=cursor.getCount();
结果=新字符串[计数];
for(int i=0;i
}

以下是日志显示:

12-28 00:04:05.106 1554-1651/?E/TaskPersister:访问最近目录(目录不存在?)时发生文件错误。
12-28 00:04:15.182 1554-1795/? I/ActivityManager:从UID10009启动u0{cmp=com.example.project2/.Categories\u word.Categories\u wordview 1}
12-28 00:04:15.194 1380-2231/? W/audio_hw_generic:没有向HAL提供足够的数据,预期位置为3729276,仅写入3728880
12-28 00:04:15.315 3259-3259/? I/System.out:删除完成
12-28 00:04:15.401 3259-3259/? I/System.out:创建表格word成功
12-28 00:04:15.409 3259-3259/? I/System.out:插入
12-28 00:04:15.411 3259-3259/? I/System.out:事务尝试
12-28 00:04:15.412 3259-3259/? I/System.out:事务处理时
12-28 00:04:15.412 3259-3259/? I/System.out:插入word(word\u id、类别\u id\u fk、word\u kor)值(100, 100, '안녕하세요');
12-28 00:04:15.413 3259-3259/?E/SQLiteLog:(1)没有此类列:100
12-28 00:04:15.413 3259-3259/?D/AndroidRuntime:关闭虚拟机
12-28 00:04:15.418 3259-3259/?E/AndroidRuntime:致命异常:主
进程:com.example.project2,PID:3259
java.lang.RuntimeException:无法启动活动组件信息{com.example.project2/com.example.project2.Categories\u word.Categories\u wordview1}:android.database.sqlite.SQLiteException:无此类列:100(代码1):,编译时:插入word(word\u id、category\u id\u fk、word\u kor)值(100, 100, '안녕하세요');
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)上
位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
位于android.app.ActivityThread.-wrap11(未知来源:0)
在android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
位于android.os.Handler.dispatchMessage(Handler.java:105)
位于android.os.Looper.loop(Looper.java:164)
位于android.app.ActivityThread.main(ActivityThread.java:6541)
位于java.lang.reflect.Method.invoke(本机方法)
在com。
public class DB_Word extends SQLiteOpenHelper {

public DB_Word(Context context){
    super(context, "word.db", null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("create table if not exists word (word_id integer primary key, category_id_fk integer, word_kor text, word_eng text, word_pro text, foreign key(category_id_fk) references category(category_id));");
    System.out.println("Create table word success");
}

@Override

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("drop table word;");
    onCreate(db);
}
public class Categories_wordview1 extends AppCompatActivity {

ArrayAdapter<String> Adapter;
ListView wordlist;

DB_Word dbc;
SQLiteDatabase db;

String sql;
Cursor cursor;
String[] result;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_category_wv);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    wordlist = (ListView) findViewById(R.id.wordlist);
    dbc = new DB_Word(this);

    delete();
    insertAll();
    select();
}

public void delete(){
    try {
        System.out.println("delete complete");
        db = dbc.getWritableDatabase();
        db.execSQL("delete from word;");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public void select(){
    System.out.println("select");
    try {
        System.out.println("select try");
        db = dbc.getReadableDatabase();
        sql = "select word_kor, word_eng, word_pro from word;";
        cursor = db.rawQuery(sql, null);
        int count = cursor.getCount();
        result = new String[count];

        for(int i = 0; i < count; i++){
            System.out.println("select for");
            cursor.moveToNext();
            String str_kor = cursor.getString(0);
            String str_eng = cursor.getString(1);
            String str_pro = cursor.getString(2);
            result[i] = str_kor + "  " + str_eng + "  " + str_pro;
        }

        Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, result);
        wordlist.setAdapter(Adapter);
        wordlist.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

public void insertAll(){
    System.out.println("insert");

    db = dbc.getWritableDatabase();
    InputStream is = this.getResources().openRawResource(R.raw.word_db);
    BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
    String tableName ="word";
    String columns = "word_id, category_id_fk, word_kor";
    String str1 = "insert into " + tableName + "(" + columns + ") values(";
    String str2 = ");";
    String line ="";

    db.beginTransaction();
    try {
        System.out.println("transaction try");
        while ((line = buffer.readLine()) != null) {
            System.out.println("transaction while");
            StringBuilder sb = new StringBuilder(str1);
            String[] str = line.split(",");
            sb.append(str[0] + ", ");
            sb.append(str[1] + ", '");
            sb.append(str[2] + "'");
            sb.append(str2);
            System.out.println(sb.toString());
            db.execSQL(sb.toString());
            //db.rawQuery(sb.toString(), null);
        }
        db.setTransactionSuccessful();
        db.endTransaction();
    }
    catch (IOException ex) {
        ex.printStackTrace();
    }
    finally {
            try {
                is.close();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
    }

}
12-28 00:04:05.106 1554-1651/? E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
12-28 00:04:15.182 1554-1795/? I/ActivityManager: START u0 {cmp=com.example.project2/.Categories_word.Categories_wordview1} from uid 10009
12-28 00:04:15.194 1380-2231/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3729276 , only wrote 3728880
12-28 00:04:15.315 3259-3259/? I/System.out: delete complete
12-28 00:04:15.401 3259-3259/? I/System.out: Create table word success
12-28 00:04:15.409 3259-3259/? I/System.out: insert
12-28 00:04:15.411 3259-3259/? I/System.out: transaction try
12-28 00:04:15.412 3259-3259/? I/System.out: transaction while
12-28 00:04:15.412 3259-3259/? I/System.out: insert into word(word_id, category_id_fk, word_kor) values(100, 100, '안녕하세요');
12-28 00:04:15.413 3259-3259/? E/SQLiteLog: (1) no such column: 100
12-28 00:04:15.413 3259-3259/? D/AndroidRuntime: Shutting down VM
12-28 00:04:15.418 3259-3259/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.example.project2, PID: 3259
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.project2/com.example.project2.Categories_word.Categories_wordview1}: android.database.sqlite.SQLiteException: no such column: 100 (code 1): , while compiling: insert into word(word_id, category_id_fk, word_kor) values(100, 100, '안녕하세요');
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                     at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                     at android.os.Handler.dispatchMessage(Handler.java:105)
                                                     at android.os.Looper.loop(Looper.java:164)
                                                     at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                  Caused by: android.database.sqlite.SQLiteException: no such column: 100 (code 1): , while compiling: insert into word(word_id, category_id_fk, word_kor) values(100, 100, '안녕하세요');
                                                     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
                                                     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
                                                     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                                                     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                                                     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
                                                     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
                                                     at com.example.project2.Categories_word.Categories_wordview1.insertAll(Categories_wordview1.java:117)
                                                     at com.example.project2.Categories_word.Categories_wordview1.onCreate(Categories_wordview1.java:51)
                                                     at android.app.Activity.performCreate(Activity.java:6975)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
                                                     at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:105) 
                                                     at android.os.Looper.loop(Looper.java:164) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:6541) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
12-28 00:04:15.483 1554-1566/? W/ActivityManager:   Force finishing activity com.example.project2/.Categories_word.Categories_wordview1
12-28 00:04:15.503 1554-1566/? W/ActivityManager:   Force finishing activity com.example.project2/.Categories