2017-03-09 99 views
0

我執行在嵌入式數據庫H2這個SQL H2說法,但我得到了一個錯誤:無法執行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)); 

回答

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); 
0

「71」 似乎是這個問題。您可能需要'71'。