小编Min*_*rip的帖子

Android:列'_id'不存在

我收到了这个错误

IllegalArgumentException:列'_id'不存在

当使用a SimpleCursorAdapter从我的数据库中检索时,表确实有这个_id列.注意到这是一个常见问题,我尝试在线解决一些解决方案,但没有一个能够解决.这是我的游标查询:

SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.quoterow, myCursor, new String[]{"_id", "quote"}, new int[]{R.id.quote});
Run Code Online (Sandbox Code Playgroud)

虽然我应该提到原来没有包含该_id列,但我最近添加了这个以尝试解决问题.有没有人有任何可能有助于解决问题的想法?

sqlite android android-sqlite android-cursoradapter

8
推荐指数
1
解决办法
1万
查看次数

Android中的游标错误告诉我列不存在

我的应用程序需要返回包含一堆引号的游标,具体取决于所选的作者.现在,我正在编写应用程序的硬编码,因此它只返回一个作者的引号.

错误发生在我的游标适配器参数中,设置"到"列,它告诉我此列"引用"不存在.

我已经尝试将to参数更改为KEY_QUOTE,甚至尝试更改实际数据库列的名称,但现在仍然很高兴.

我究竟做错了什么?

以下是此操作中使用的代码块.

  1. 创建数据库表,报价
  2. 填充此表
  3. 查询报价
  4. 打开数据库连接,创建游标(我获取实际错误,使用"from"参数)

1.

private static final String CREATE_QUOTE_TABLE = 

            "create table " + QUOTES_TABLE +
            " (_id integer primary key autoincrement, " + 
            "auth_name text not null, " +
            "myQuote text not null, " +
            "category text not null);";
Run Code Online (Sandbox Code Playgroud)

2.

public long populateQuotes(){

    ContentValues initialValues = new ContentValues();

    long[] rowIds = new long[authorName.length];

    // Add wilson quotes category: Anthropology
    for(int i = 0; i < 3; i++){
        initialValues.put(KEY_AUTHNAME, authorName[3]);
        initialValues.put(KEY_QUOTE, quoteRAW[i]); …
Run Code Online (Sandbox Code Playgroud)

sqlite android cursor

6
推荐指数
1
解决办法
4468
查看次数

Java SQL:结果集之前的错误

我的java应用程序中的查询有问题.这是一个简单的查询,根据他们的名字获得用户得分,但是,我经常收到错误,无法找出问题的来源.

            String driver = "com.mysql.jdbc.Driver";    
        Class.forName(driver).newInstance();

        con = DriverManager.getConnection(url, USERNAME, PASSWORD);   
        st  = con.createStatement();


        PreparedStatement preStatement = con.prepareStatement("select score from playerscore where name=?");
        preStatement.setString(1, "tomcat");

        ResultSet resultSet = preStatement.executeQuery();
        score               = resultSet.getInt(1);
Run Code Online (Sandbox Code Playgroud)

有人会注意并指出我正确的方向吗?

编辑:堆栈跟踪的图像

http://imageshack.us/photo/my-images/854/stackr.jpg/

java sql resultset

1
推荐指数
1
解决办法
1746
查看次数