2

On my own machine I modify postgresql.conf, but I don't think Heroku gives access to that file. Does anyone know any alternative methods to set the default schema?

Setting it on every connection seems kinda ugly.

2
  • 3
    If you always want to use that schema, you can make it the default schema by running alter user set schema 'default_schema' Commented Oct 18, 2013 at 6:23
  • thanks horse. should add as answer. Commented Oct 18, 2013 at 23:20

1 Answer 1

2

Create user in postgres db with same name as schema name. Login with this new user, it will automatically point to schema with user.

  <GlobalNamingResources>
  <Resource name="jdbc/DatabaseName" auth="Container" type="javax.sql.DataSource"
              username="acme" password="dbPasswd"
              url="jdbc:postgresql://localhost/mydb"
              driverClassName="org.postgresql.Driver"
              initialSize="5" maxWait="5000"
              maxActive="120" maxIdle="5"
              validationQuery="select 1"
              poolPreparedStatements="true"/>
</GlobalNamingResources/>

with this configuration, jndi lookup for resource "jdbc/DatabaseName" with return database connection pointing to schema name matching user "acme", ie acme.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.