I created the Spring Boot web application using the Spring Initializer, the built-in Tomcat, the Thymeleaf template engine, and the package as an executable JAR file.
Technologies used:
Spring Download 1.4.2.RELEASE, Spring 4.3.4.RELEASE, Thymeleaf 2.1.5.RELEASE, Tomcat Paste 8.5.6, Maven 3, Java 8
This is the bean I call when starting DB
@SpringBootApplication @EnableAutoConfiguration @Import({SecurityConfig.class}) public class BookApplication { public static void main(String[] args) { SpringApplication.run(BookApplication.class, args); } } @Configuration public class PersistenceConfig { ... @Bean public DataSource dataSource(){ return (new EmbeddedDatabaseBuilder()) .addScript("classpath:db/H2.schema.sql") .addScript("classpath:db/H2.data.sql") .build(); }
When I launched 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 Links -> SQL Scrapbook - everything is in order!
adding SHOW CREATE FUNCTION PARSEDATETIME to 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 a suggested example:
Failed to execute SQL script statement