一旦我打开我的应用程序,它就会提示我不幸的是,数据库已停止
public class Databasetest extends Activity {
private CommentDataSource datasource;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_databasetest);
datasource = new CommentDataSource(this);
datasource.open();
}
}
以下是我得到的错误,有人可以告诉我这是什么意思吗?..
(1) near "studentinfo_db": syntax error
这是我的 DataCommentSource :
public class CommentDataSource {
private SQLiteDatabase db;
private MySQLiteHelper dbHlp;
private String[] allColumns = { StudentInfo.COL_ROW_ID,
StudentInfo.COL_STUDENT_NAME };
public CommentDataSource(Context context) {
dbHlp = new MySQLiteHelper(context);
}
public void open() throws SQLException {
db= dbHlp.getWritableDatabase();
}
public void close() {
dbHlp.close();
}
}
这是我的 MySQLiteHelper:
public class MySQLiteHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "studentsresult.db";
private static final int DATABASE_VERSION = 1;
public MySQLiteHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(StudentInfo.SQL_TABLE_NAME);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(MySQLiteHelper.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + StudentInfo.SQL_TABLE_NAME);
onCreate(db);
}
}
上面我已经上传了我的源代码。