【问题标题】:Error when calling Stored Procedure in Spring Boot application在 Spring Boot 应用程序中调用存储过程时出错
【发布时间】:2019-03-23 23:31:35
【问题描述】:

我在 Spring Boot 应用程序中调用存储过程,但是在使用 IntelliJ IDEA 时它可以完美运行,但是当我创建 Jar 文件并执行它时,出现以下错误:

2018-10-18 22:45:41.721  WARN 8864 --- [nio-8082-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 201, SQLState: 37000
2018-10-18 22:45:41.721 ERROR 8864 --- [nio-8082-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : Procedure password_change_web expects parameter @id_usuario_int, which was not supplied.

2018-10-18 22:45:41.721  WARN 8864 --- [nio-8082-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 201, SQLState: 37000
2018-10-18 22:45:41.721 ERROR 8864 --- [nio-8082-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : Procedure password_change_web expects parameter @password, which was not supplied.

2018-10-18 22:45:41.746 ERROR 8864 --- [nio-8082-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error calling CallableStatement.getMoreResults; SQL [password_change_web]; nested exception is org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults] with root cause

java.sql.SQLException: Procedure password_change_web expects parameter @id_usuario_int, which was not supplied.

我正在使用 Spring Boot 2.0.6.RELEASE 和 Spring Data。

存储库中的代码是:

@Procedure
void password_change_web(Integer idUsuarioIntranet, String password);

有什么想法吗?

【问题讨论】:

  • 您确定要传递所需的参数@id_usuario_int,但未提供。?分享您的代码以重现问题
  • 名称不应该完全匹配吗? idUsuarioInt 而不是 idUsuarioIntranet?
  • @Barath 是的,我确定参数值不为空。奇怪的是,使用 IntelliJ IDEA 中的应用程序可以完美运行,但使用 Jar 却给了我错误。
  • @Patrick 我会尝试这种方法,如果可行,我会告诉你。
  • @Patrick 你是对的。参数的名称必须相同。感谢您的帮助。

标签: hibernate spring-boot stored-procedures spring-data


【解决方案1】:

请注意,参数应与正确的名称匹配。你的情况

@Procedure
void password_change_web(Integer idUsuarioIntranet, String password);

应该改为:

@Procedure
void password_change_web(Integer idUsuarioInt, String password);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-03
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 2017-05-12
    • 2017-02-18
    相关资源
    最近更新 更多