简体   繁体   English

用spring执行存储过程

[英]Execute stored procedure with spring

When I try to execute stored procedure with spring the this exception is thrown: 当我尝试使用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)

I'm using myfaces 1.2.5, spring 2.0.2 我正在使用myfaces 1.2.5,春季2.0.2

The first argument is Integer and the last is NUMBER. 第一个参数是Integer,最后一个参数是NUMBER。 The mapping of the Oracle Types and Java types are as follows: Oracle类型和Java类型的映射如下:

Integer -> Numeric
NUMBER -> Decimal.

My question is what is the reason of this exception and how to fix it? 我的问题是此异常的原因是什么以及如何解决?

Thanks in advance. 提前致谢。

The error originates from LINE 53 of TEST.TEST_PKG 错误源自TEST.TEST_PKG的LINE 53

There seems to be an INSERT statement with incorrect binding types. 似乎有不正确的绑定类型的INSERT语句。

The problem was from the new rows in text inserted in the DB. 问题出在数据库中插入的新行中。 I just call replacaAll("\\n","") and now everything works fine. 我只是调用replacaAll(“ \\ n”,“”),现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM