无法执行H2语句

时间:2017-03-09 18:05:37

标签: sql h2

我在嵌入式数据库H2中执行此SQL H2语句,但是我收到错误:

  Factory method 'dataSource' threw exception; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #13 of class path resource [db/H2.data.sql]: insert into T_DEVICE_EVENT (ID, DEVICE_ID, LATITUDE, LONGITUDE, MESSAGE, DATE_RECEIVED, RSSI, BATTERY, ALARM, PROCESSED) values (1,1,50.834015,4.377885,'71',CURRENT_TIMESTAMP(),70,50,0,1); nested exception is java.sql.SQLSyntaxErrorException: unexpected token: ( required: )

CREATE TABLE IF NOT EXISTS t_device_event (
    id              bigint PRIMARY KEY,
    device_id       bigint NOT NULL,
    latitude        decimal NULL,
    longitude       decimal NULL,
    message         varchar(100) ,
    date_received   timestamp,
    rssi            float,
    battery         int,
    alarm           boolean,
    processed       boolean,
    FOREIGN KEY (device_id) REFERENCES public.t_device(id));

2 个答案:

答案 0 :(得分:0)

" 71"似乎是问题所在。你可能想要' 71'代替。

答案 1 :(得分:0)

问题出在CURRENT_TIMESTAMP()上,您必须删除括号:

insert into T_DEVICE_EVENT (ID, DEVICE_ID, LATITUDE, LONGITUDE, MESSAGE, DATE_RECEIVED, RSSI, BATTERY, ALARM, PROCESSED) values (1,1,50.834015,4.377885,'71',CURRENT_TIMESTAMP,70,50,0,1);