# Specifying database schema when instantiating Liquibase with Spring

**URL:** <https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992>\
**Category:** General Discussion\
**Created:** [December 9, 2010, 11:07pm UTC](https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992 "2010-12-09T23:07:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradley\_lb](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bradley\_lb](https://forum.liquibase.org/u/bradley_lb)\
**Post date:** [December 9, 2010, 11:07pm UTC](https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992/1 "2010-12-09T23:07:00Z")

</div>

Hi, we’re using the following to start Liquibase from Spring:

&nbsp; &nbsp; 

The problem we’re running into is that in some cases our application will run in a different database schema than the “default” one (i.e. the one with the same name as the datasource’s connecting username). I can’t figure out a way to pass a schema name to Liquibase via Spring.

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [December 9, 2010, 11:07pm UTC](https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992/2 "2010-12-09T23:07:00Z")

</div>

It looks like the SpringLiquibase class does not support setting the defaultSchema currently.&nbsp; You should be able to subclass SpringLiquibase and override the createLiquibase() method to call super.createLiquibase() then call setDefaultSchema(YOUR\_SCHEMA) on the object returned from the superclass call.

I’ll add a defaultSchema property to the class for the next release.

Nathan

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [December 9, 2010, 11:07pm UTC](https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992/3 "2010-12-09T23:07:00Z")

</div>

Sorry, it is on createDatabase().&nbsp; It should be:

&nbsp; &nbsp; protected Database createDatabase(Connection c) throws DatabaseException { &nbsp; &nbsp; &nbsp; &nbsp; Database database = super.createDatabase(c); &nbsp; &nbsp; &nbsp; &nbsp; database.setDefaultSchemaName(YOUR SCHEMA); &nbsp; &nbsp; &nbsp; &nbsp; return database; &nbsp; &nbsp; }

Nathan

---

<div class="post-metadata">

**Author:** ![bradley\_lb](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bradley\_lb](https://forum.liquibase.org/u/bradley_lb)\
**Post date:** [December 9, 2010, 11:07pm UTC](https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992/4 "2010-12-09T23:07:00Z")

</div>

Hmm the SpringLiquibase.createLiquibase method is private and there doesn’t appear to be a createDatabase method in the SpringLiquibase class.

I’m on version 1.9.4

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [December 9, 2010, 11:07pm UTC](https://forum.liquibase.org/t/specifying-database-schema-when-instantiating-liquibase-with-spring/992/5 "2010-12-09T23:07:00Z")

</div>

Sorry, I had just looked at the 2.0 codebase.&nbsp;

It will probably be easiest for you to just copy/paste the default SpringLiquibase method and modify it to fit your needs.&nbsp; I’m not sure if there will be another 1.9 release or not to make the change in the codebase.

Nathan
