I have a Spring Boot application that has an embedded in-memory Derby DB and schema.sql
is executed by Spring Boot at startup.
schema.sql:
create schema demo;
create table users (id varchar(10) primary key, name varchar(30), password varchar(30), mail varchar(100));
insert into users (id, name) values ('admin','admin');
I wanted to introduce spring-boot-devtools
to automatically reload changes in my application, so I added the dependency to pom.xml.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
However, the above SQLs causes SQLExceptions and fails to reload because the schema and table has already exist.
So I tried to add the following SQLs, but if exists
clause cannot be used in Derby.
drop schema if exists demo;
drop table if exists users;
Could anyone tell me the solution (alternative SQLs or how to ignore the SQL exceptions)?