【问题标题】:Spring boot jdbc template not finding table in postgres under custom schemaSpring Boot jdbc模板在自定义模式下的postgres中找不到表
【发布时间】:2017-11-27 15:52:14
【问题描述】:

我的数据库有一些模式,我创建了一个名为应用程序的应用程序来保存我的应用程序特定的表。我将此模式添加到 postgres 的 search_path,但是当我使用 jdbc 模板进行查询时,它找不到表。如何让 jdbc 使用 search_path 来查找正在查询的表?

【问题讨论】:

    标签: postgresql spring-boot spring-jdbc jdbctemplate


    【解决方案1】:

    有几种选择:

    1) 您可以在每个会话开始时set search_path to ..;,或

    2) 你可以alter database yourdatabase set search_path to ...;,或者

    3) 你可以alter role yourdbuser set search_path to ...;。

    选项 2 和 3 仅适用于新连接(不要忘记重新连接)。

    另外,你可以在 postgresql.conf 中设置search_path,但是如果你有超过 1 个数据库,这个选项就不那么灵活了。

    【讨论】:

      猜你喜欢
      • 2012-01-04
      • 2021-09-04
      • 1970-01-01
      • 2020-04-17
      • 2018-08-10
      • 2017-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多