开发者

Problems with SQLite database, error when creating

i got this error when i start my app:

12-20 22:27:01.447: ERROR/Database(716): Failure 1 (near ":00": syntax error) on 0x1a4338 when preparing 'CREATE TABLE permission ( fk_email1 varchar(100) NOT NULL, fk_email2 varchar(100) NOT NULL, validated tinyint(4) default 0, hour1 time default 08:00:00, hour2 time default 20:00:00, date1 date default NULL, date2 date default NULL, weekend tinyint(4) default 0, fk_type varchar(45) default NULL, PRIMARY KEY (fk_email1,fk_email2))'.

here is the code where i am creating the database:

private static final String PERMISSION_TABLE_CREATE = 开发者_开发百科
"CREATE TABLE permission (" 
"fk_email1 varchar(100) NOT NULL, fk_email2 varchar(100) NOT NULL, "
"validated tinyint(4) default 0, hour1 time default 08:00:00, "
"hour2 time default 20:00:00, date1 date default NULL, "
"date2 date default NULL, weekend tinyint(4) default 0, "
"fk_type varchar(45) default NULL, PRIMARY KEY  (fk_email1,fk_email2))";

private static final String USER_TABLE_CREATE = "CREATE TABLE user ( "
"email varchar(100) NOT NULL, password varchar(45) default NULL, "
"fullName varchar(80) default NULL, "
"mobilePhone varchar(14) default NULL, "
"mobileOperatingSystem varchar(20) default NULL, PRIMARY KEY  (email))";

what i am doing bad?


Check the SQLLite documentation. I don't believe it has a type affinity for the "TIME" datatype. If it does, the defaults will probably have to be in quotes.

SQLite is very funny about datatypes (essentially, all data is untyped) and you can substantially shorten your DDL by getting rid of VARCHAR lengths (or even VARCHAR in favor of TEXT).


Obviously definition of your time row is wrong

Please check SQLite docs

You can try "YYYY-MM-DD HH:MM:SS.SSS" format, but better store value as an INTEGER (Unix Time)


http://www.sqlite.org/faq.html#q2

(2) What datatypes does SQLite support?

SQLite uses dynamic typing. Content can be stored as INTEGER, REAL, TEXT, BLOB, or as NULL.

Use INTEGER, for instance, it can store Java's long.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜