NullPointerException
NullPointerException

Reputation: 37577

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?

Upvotes: 0

Views: 944

Answers (3)

Larry Lustig
Larry Lustig

Reputation: 50970

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).

Upvotes: 2

Vit Khudenko
Vit Khudenko

Reputation: 28418

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.

Upvotes: 1

kzotin
kzotin

Reputation: 5365

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)

Upvotes: 1

Related Questions