开发者社区> 问答> 正文

Android数据库一直报错,不知道什么原因了??报错

这个是报错情况:

05-18 12:21:49.976: I/Database(5166): sqlite returned: error code = 1, msg = near "order": syntax error
05-18 12:21:49.976: E/Database(5166): Failure 1 (near "order": syntax error) on 0x2c4958 when preparing 'create table dict2 (_id integer primary key autoincrement , dev_id varchar(300) , receiver varchar(300) , receive_time varchar(300) , info_source varchar(300) , task_type varchar(300) , task_id varchar(300) , task_name varchar(300) , order varchar(300) , location varchar(300) , event_time varchar(30) , pic_path_down varchar(30) , vehicle_fault_num varchar(300) , vehicle_fault_type varchar(300) , parking_position varchar(300) , cargo varchar(300), wrecker_num varchar(300) , wrecker_type varchar(300) , driver varchar(300) , co_driver varchar(300) , state varchar(300))'.
这个是源码不知道哪里有问题了

final String CREATE_TABLE_SQL = "create table dict2 (_id integer primary key autoincrement , dev_id varchar(300) , receiver varchar(300) , receive_time varchar(300) , info_source varchar(300) , task_type varchar(300) , task_id varchar(300) , task_name varchar(300) , order varchar(300) , location varchar(300) , event_time varchar(30) , pic_path_down varchar(30) , vehicle_fault_num varchar(300) , vehicle_fault_type varchar(300) , parking_position varchar(300) , cargo varchar(300), wrecker_num varchar(300) , wrecker_type varchar(300) , driver varchar(300) , co_driver varchar(300) , state varchar(300))";
 public MyDatabaseHelper(Context context, String name, CursorFactory factory,int version)
 {
  super(context,name,null,version);
 }
 public void onCreate(SQLiteDatabase db)
 {
  db.execSQL(CREATE_TABLE_SQL);
    System.out.println("44");
  String insertStr1 = "insert into dict2(dev_id,receiver,receive_time,info_source,task_type,task_id,task_name,order,location,event_time,pic_path_down,vehicle_fault_num,vehicle_fault_type,parking_position,cargo,wrecker_num,wrecker_type,driver,co_driver,state) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  String[] insertValue1_1 = { "抛锚","东2","514134","0","3","抛锚","东2","514134","0","3","抛锚","东2","514134","0","3","抛锚","东2","514134","0","3"};
  db.execSQL(insertStr1, insertValue1_1);
 }

 

展开
收起
爱吃鱼的程序员 2020-06-20 19:09:20 561 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    order是SQL中的关键字,不能作为表的字段

    2020-06-20 19:09:36
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载