问题
I'm trying to set up EmbeddedDatabase for testing in Spring and I'm getting the following error: java.sql.SQLSyntaxErrorException: Schema 'SA' does not exist
.
From the following code:
private DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.setType(EmbeddedDatabaseType.DERBY)
.addScript("tables_data.sql")
.build();
}
SQL is:
CREATE TABLE person (
id BIGSERIAL,
name varchar(200)
);
Been searching around for few hours. Haven't find a solution.
回答1:
Have you tried simply creating an SA schema? Honestly I have never used Derby, but one thing I've learned is that any time you use two frameworks together there will always be little quirks.
回答2:
Just add a CREATE SCHEMA
line to the top of your SQL. So your SQL should look like this:
CREATE SCHEMA SA;
CREATE TABLE person (
id BIGSERIAL,
name varchar(200)
);
来源:https://stackoverflow.com/questions/38272091/spring-embeddeddatabase-with-derby-requiring-schema