SQLite在BlackBerry OS 6中的游标出现故障

5

我有一个应用程序,在BlackBerry OS 7.0下运行良好,但当我在BlackBerry OS 6.0下运行相同的应用程序时,SqLite光标立即到达数据结尾,因此我无法从数据库中提取任何数据。

 public static Vector GetProducts(String sysID) {
  Bitmap img = null;
  try {
   Statement st = d
     .createStatement("SELECT * FROM Product where systemSerID=?");
   st.prepare();
   st.bind(1, sysID);
   st.execute();
   Cursor c = st.getCursor();

   Products products;
   Vector pro = new Vector();

   while (c.next()) {

    Row r = c.getRow();
    products = new Products();
    products.setSystemServiceID(r.getString(1));
    products.setSystemServiceName(r.getString(2));
    products.setProductID(r.getString(3));
    products.setProductName(r.getString(4));
    products.setProductDesc(r.getString(5));

    products.setProductType(r.getString(devil));
    // products[i].setProductType("1");
    products.setBatchID(r.getString(7));
    products.setMinValue(r.getString(music));
    products.setMaxValue(r.getString(9));
    products.setImageURL(r.getString(10));

    System.out.println(" retrived from database.");
    pro.addElement(products);
   }

   c.close();
   st.close();
   return pro;

  } catch (DatabaseException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   return null;

  } catch (DataTypeException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   return null;
  }

 }
1个回答

3
数据库文档中提到:

如果语句可能返回结果,则通过调用Statement.getCursor()来运行该语句。 Statement.execute() - 当您希望明确准备和关闭语句时使用。

由于您希望访问结果集,因此不应调用Statement.execute()。getCursor()会导致查询执行,因此您应该能够删除execute()调用以获得所需的行为。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接