微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

嵌套异常是 org.postgresql.util.PSQLException:错误:关系“equ_config”不存在

如何解决嵌套异常是 org.postgresql.util.PSQLException:错误:关系“equ_config”不存在

我正在用 springboot + mybatis + Yugabyte 开发一个后端程序。 它在开发环境中运行良好,但在在线环境中出现以下错误

2021-04-14 13:52:15.123 [http-nio-8080-exec-8] DEBUG com.yoi.config.infrastructure.repository.mapper.ConfigMapper.liteConfigByType - ==>  Preparing: select * from "equ_config" where conf_type = ? and conf_df = true order by conf_order desc; 
2021-04-14 13:52:15.133 [http-nio-8080-exec-8] DEBUG com.yoi.config.infrastructure.repository.mapper.ConfigMapper.liteConfigByType - ==> Parameters: dept(String)
2021-04-14 13:52:15.459 [http-nio-8080-exec-8] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing Failed; nested exception is org.springframework.jdbc.BadsqlGrammarException: 
### Error querying database.  Cause: org.postgresql.util.PsqlException: ERROR: relation "equ_config" does not exist
  Position: 16
### The error may exist in URL [jar:file:/srvmgmt/java/target/equip-management-server.jar!/BOOT-INF/classes!/mapper/ConfigMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### sql: select * from  "equ_config" where conf_type = ? and conf_df = true         order by conf_order desc;
### Cause: org.postgresql.util.PsqlException: ERROR: relation "equ_config" does not exist
  Position: 16
; bad sql grammar []; nested exception is org.postgresql.util.PsqlException: ERROR: relation "equ_config" does not exist
  Position: 16] with root cause
org.postgresql.util.PsqlException: ERROR: relation "equ_config" does not exist
  Position: 16
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532) ~[postgresql-42.2.14.jar!/:42.2.14]

映射器如下所示:

    <select id="liteConfigByType" resultType="com.yoi.config.infrastructure.repository.po.ConfigPO">
     select * from  equ_config where conf_type = #{type} and conf_df = true
        order by conf_order desc;
    </select>

查询 sql select * from equ_config where conf_type = 'dept' and conf_df = true order by conf_order desc; 在 Navicat Gui 中运行良好,在线应用启动良好。

我不知道出了什么问题。

解决方法

对我来说,这看起来像是某个地方的配置问题。如果没有更多信息,就很难找出问题的根本原因。可能是这样:

  • 实际上并未创建该表。
  • 赠款设置不正确。
  • PROD 中的帐户可能不同。
  • 表名、前缀或后缀中可能有不同的大小写。
  • 你说出它的名字...

一个可以帮助您诊断问题的技巧可以采用查询 information_schema 的 que 形式,从应用程序本身运行,以找出应用程序看到的内容。我的 MyBatis 映射器中有一些“额外”查询,如下所示:

<select id="searchTable" resultType="FoundTableVO">
  select table_schema,table_name
  from information_schema.tables
  where lower(table_name) like '%equ_config%'
</select>

上面的查询将列出所有看起来像您的表的表,以及它们所在的架构。像这样的一些查询将阐明这个问题。

,

确保表 equ_config 在模式 public 中。如果不是,请在您的表中使用 qweries 尝试以下语法:“schema_name.equ_config”

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?