【问题标题】:Setting default schema in postgresql (spring)在 postgresql (spring) 中设置默认模式
【发布时间】:2013-10-26 19:05:49
【问题描述】:

在我自己的机器上我修改了postgresql.conf,但我不认为 Heroku 允许访问该文件。有谁知道设置默认架构的任何替代方法?

在每个连接上都设置它似乎有点难看。

【问题讨论】:

  • 如果您总是想要使用该架构,您可以通过运行 alter user set schema 'default_schema' 使其成为默认架构
  • 感谢马。应该添加为答案。

标签: java spring postgresql heroku


【解决方案1】:

在 postgres db 中创建与模式名称同名的用户。用这个新用户登录,它会 自动指向用户的架构。

  <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/>

使用此配置,jndi 查找资源“jdbc/DatabaseName”并返回指向与用户“acme”匹配的架构名称的数据库连接,即 acme。

【讨论】:

    猜你喜欢
    • 2015-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    • 2012-08-17
    • 1970-01-01
    • 2015-09-24
    • 2017-05-27
    相关资源
    最近更新 更多