Spring EmbeddedDatabase with Derby requiring schema

青春壹個敷衍的年華 提交于 2019-12-11 07:32:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!