I've generated a Spring Boot web application using Spring Initializer, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file.
Technologies used:
Spring Boot 1.4.2.RELEASE, Spring 4.3.4.RELEASE, Thymeleaf 2.1.5.RELEASE, Tomcat Embed 8.5.6, Maven 3, Java 8
This is a bean I call when starting the DB
@SpringBootApplication @EnableAutoConfiguration @Import({SecurityConfig.class}) public class BookApplication { public static void main(String[] args) { SpringApplication.run(BookApplication.class, args); } } @Configuration public class PersistenceConfig { ... /** * Creates an in-memory "books" database populated * with test data for fast testing */ @Bean public DataSource dataSource(){ return (new EmbeddedDatabaseBuilder()) .addScript("classpath:db/H2.schema.sql") .addScript("classpath:db/H2.data.sql") .build(); } When I execute this insert in
CREATE TABLE IF NOT EXISTS t_time_lapse ( id bigint PRIMARY KEY, name varchar(50) NOT NULL, description varchar(200) NOT NULL, sunday boolean DEFAULT NULL, monday boolean DEFAULT NULL, tuesday boolean DEFAULT NULL, wednesday boolean DEFAULT NULL, thursday boolean DEFAULT NULL, friday boolean DEFAULT NULL, saturday boolean DEFAULT NULL, init_period date NOT NULL , end_period date NOT NULL , init_time time DEFAULT NULL, end_time time DEFAULT NULL, company_id bigint DEFAULT NULL, FOREIGN KEY (company_id) REFERENCES public.t_company(id) ); insert into T_TIME_LAPSE (ID, NAME, DESCRIPTION, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY, INIT_PERIOD, END_PERIOD, INIT_TIME, END_TIME, COMPANY_ID) values (9090,'key', 'key', 1,1,1,1,1,1,1,CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, PARSEDATETIME('03:05:06 GMT','HH:mm:ss z', 'en', 'GMT'), PARSEDATETIME('03:05:06 GMT','HH:mm:ss z', 'en', 'GMT'), 1); I got this error
user lacks privilege or object not found: PARSEDATETIME Executing the same query in the Data Source Explorer -> DataBase Connections -> SQL Scrapbook everything is fine !
adding SHOW CREATE FUNCTION PARSEDATETIME in the script:
Failed to execute SQL script statement #1 of class path resource [db/H2.data.sql]: SHOW CREATE FUNCTION PARSEDATETIME; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: SHOW and CREATE FUNCTION PARSEDATETIME;
Failed to execute SQL script statement #1 of class path resource [db/H2.data.sql]: CREATE FUNCTION PARSEDATETIME; nested exception is java.sql.SQLSyntaxErrorException: unexpected end of statement: required: ( and with the proposed example :
Failed to execute SQL script statement #2 of class path resource [db/H2.data.sql]: INSERT INTO test values (1, CALL PARSEDATETIME('03:05:06 GMT','HH:mm:ss z', 'en', 'GMT')); nested exception is java.sql.SQLSyntaxErrorException: unexpected token: CALL
T_TIME_LAPSEschema? please add the DDL.CREATE TABLE test ( id INT NOT NULL, birthday TIMESTAMP ); INSERT INTO test values (1, CALL PARSEDATETIME('03:05:06 GMT','HH:mm:ss z', 'en', 'GMT'));on data.sql