首页 新闻 会员 周边 捐助

请教android高手,该问题如何解决。

0
悬赏园豆:20 [待解决问题]

myeclipse Debug时出现JDI thread evaluations (Tiem of error : ) Reason:check the details

贴一下代码:MyHelper类代码

public class MyHelper extends SQLiteOpenHelper {

 public static final String DB_NAME = "product.db";
 public static final int VERSION = 11;
 public static String TB_NAME = "product";
 public static final String TB_NAME_COLLECTION = "collection";
 public static final String ID = "_id";
 public static final String DMCODE = "dmcode";
 public static final String PRODUCT_ID = "productid";
 public static final String NAME = "name";
 public static final String DESCRIPTION = "description";
 public static final String PRICE = "price";
 public static final String AMOUNT = "amount";
 public static final String TELEPHONE = "telephone";
 public static final String COLORNAME = "colorname";
 public static final String COLORID = "colorid";
 public static final String SIZENAME = "sizename";
 public static final String SIZEID = "sizeid";
 public static final String MODIFYDATE = "modifyDate";

 public MyHelper(Context context, String name, CursorFactory factory, int version) {
  super(context, name, factory, version);
 }
 public MyHelper(Context context, String name, CursorFactory factory, int version,String tableName) {
  super(context, name, factory, version);
  this.TB_NAME=tableName;
 }

 @Override
 public void onCreate(SQLiteDatabase db) {
  db.execSQL("CREATE TABLE IF NOT EXISTS " + TB_NAME + " (" + ID + " INTEGER PRIMARY KEY,"
    + DMCODE + " VARCHAR," + PRODUCT_ID + " VARCHAR," + NAME + " VARCHAR," + DESCRIPTION +
    " VARCHAR," + PRICE + " VARCHAR," + AMOUNT + " VARCHAR," + TELEPHONE + " VARCHAR," + COLORNAME + " VARCHAR," + COLORID
    + " VARCHAR," + SIZENAME + " VARCHAR," + SIZEID + " VARCHAR,"+ MODIFYDATE +" varchar");

 }

 @Override
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

  db.execSQL("DROP TABLE IF EXISTS " + TB_NAME);
  onCreate(db);
 }

}

抛出该异常代码:

MyHelper helper = null;
   SQLiteDatabase db = null;
   Cursor cursor = null;
   try {
    helper = new MyHelper(this, MyHelper.DB_NAME, null, MyHelper.VERSION,MyHelper.TB_NAME_COLLECTION);
    db = helper.getWritableDatabase(); 
    String sql = "select * from " + MyHelper.TB_NAME_COLLECTION
    + " where productid=?";
    cursor = db.rawQuery(sql, new String[] {id});//调试至改行抛出异常
   } catch (Exception e) {
    Log.e(TAG, " " + e.getMessage());
    e.printStackTrace();
   } finally {
    if(cursor != null)
     cursor.close();
    if(db != null)
     db.close();
    if(helper != null)
     helper.close();
   } 

求高手解决啊,本人是新手,分也不多,还望大家多多解答。。

彼岸-夕的主页 彼岸-夕 | 初学一级 | 园豆:180
提问于:2011-03-21 10:14
< >
分享
所有回答(1)
0

单独试试db.rawQuery(sql,的查询是否可以执行,你可以下载Anroid in Action 这本书的代码,其中中5.3章有个Sqlite的完整例子, 基础知识课参考 http://www.cnblogs.com/2018/category/283694.html 

2012 | 园豆:21445 (高人七级) | 2011-03-21 12:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册