【问题标题】:Execute stored procedure with spring用spring执行存储过程
【发布时间】:2023-04-01 09:07:01
【问题描述】:

当我尝试使用 spring 执行存储过程时,会抛出此异常:

    Caused by: org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call TEST_PKG.DO_IT(?, ?, ?, ?, ?, ?, ?, ?, ?)}]; SQL state [72000]; error code [1461]; ORA-01461: can bind a LONG value only for insert into a LONG column
ORA-06512: at "TEST.TEST_PKG", line 53
ORA-06512: at line 1
; nested exception is java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
ORA-06512: at "TEST.TEST_PKG", line 53
ORA-06512: at line 1

    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:124)
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:952)
    at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:985)
    at org.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:117)

我正在使用 myfaces 1.2.5,spring 2.0.2

第一个参数是 Integer,最后一个参数是 NUMBER。 Oracle类型与Java类型的映射如下:

Integer -> Numeric
NUMBER -> Decimal.

我的问题是这个异常的原因是什么以及如何解决它?

提前致谢。

【问题讨论】:

    标签: java oracle stored-procedures sqldatatypes


    【解决方案1】:

    问题出在数据库中插入的文本中的新行。我只是调用 replacaAll("\n","") 现在一切正常。

    【讨论】:

      【解决方案2】:

      错误源自 TEST.TEST_PKG 的第 53 行

      似乎有一个 INSERT 语句的绑定类型不正确。

      【讨论】:

      • 数据库开发人员已经看到了这种情况,并说数据库中一切正常。奇怪的是它可以在谷歌浏览器中运行,但不能在 IE 中运行。
      猜你喜欢
      • 2011-02-25
      • 2012-10-14
      • 2010-09-15
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 2019-12-04
      • 2011-06-19
      相关资源
      最近更新 更多