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();
}
求高手解决啊,本人是新手,分也不多,还望大家多多解答。。
单独试试db.rawQuery(sql,的查询是否可以执行,你可以下载Anroid in Action 这本书的代码,其中中5.3章有个Sqlite的完整例子, 基础知识课参考 http://www.cnblogs.com/2018/category/283694.html