本文介绍了如何在Java中调用Oracle Sproc(使用Spring 3.0)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用Spring 3.0的Java开发中,
执行为Oracle编写的Sproc时遇到问题.
这是Sproc代码:
Hi,
In Java development using Spring 3.0,
I am having problem while executing the Sproc written for Oracle.
Here is the Sproc code:
create or replace PROCEDURE
ADD_PRODUCT
( product_id IN VARCHAR2
, description IN VARCHAR2
, weight IN FLOAT
, specification IN VARCHAR2
, category IN VARCHAR2
, manufacturer IN VARCHAR2
, syncount IN NUMBER
, nonAccentedURL IN VARCHAR2
, nonAccentedManufacturer IN VARCHAR2
) AS
recCount number;
BEGIN
recCount := 0;
SELECT COUNT(*)
INTO recCount
FROM ERP_MANUFACTURER
WHERE NAME = manufacturer;
IF recCount < 1 THEN
INSERT INTO ERP_MANUFACTURER (NAME, URL) VALUES (manufacturer, nonAccentedManufacturer);
END IF;
INSERT INTO ERP_PRODUCT (ID, DESCRIPTION, WEIGHT, SPECIFICATION, CATEGORY, MANUFACTURER, SYNCCOUNT, URL)
VALUES (product_id,description,weight,specification,category,manufacturer,syncount,nonAccentedURL);
END ADD_PRODUCT;
这是代码:
Here is the Code:
public int ADD_Product(String codigo_produto, String descricao, float peso, String espeficiacao, String categoria, String fabricante, int sysCount, int SENT_STATUS) throws Exception {
SimpleJdbcCall caller = new SimpleJdbcCall(this.jdbcTemplate).withFunctionName("ADD_PRODUCT");
MapSqlParameterSource paramMap = new MapSqlParameterSource();
paramMap.addValue("product_id", codigo_produto, Types.VARCHAR);
paramMap.addValue("description", descricao, Types.VARCHAR);
paramMap.addValue("weight", peso, Types.FLOAT);
paramMap.addValue("specification",espeficiacao, Types.VARCHAR);
paramMap.addValue("category", categoria, Types.VARCHAR);
paramMap.addValue("manufacturer", fabricante, Types.VARCHAR);
paramMap.addValue("syncount", sysCount, Types.NUMERIC);
paramMap.addValue("nonAccentedURL", URLEncoder.encode(deAccent(espeficiacao).toLowerCase(), "UTF-8"), Types.VARCHAR);
paramMap.addValue("nonAccentedManufacturer", URLEncoder.encode(deAccent(fabricante).toLowerCase(), "UTF-8"), Types.VARCHAR);
Map<String, Object> i = caller.execute(paramMap);
return i.size();
}
执行此方法后,
以下是错误日志:
When this Method is Executed,
Following is the Log of Error:
org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{? = call ADD_LOG(?, ?, ?, ?)}]; nested exception is java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'ADD_LOG'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:181)
at br.edeploy.voive.dao.ProductDAO.ADD_Log(ProductDAO.java:139)
at br.edeploy.voice.service.ProdutosIn.doGet(ProdutosIn.java:277)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at br.com.caelum.vraptor.resource.DefaultResourceNotFoundHandler.couldntFind(DefaultResourceNotFoundHandler.java:41)
at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:71)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:56)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'ADD_LOG'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:191)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:944)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3482)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:3856)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1373)
at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:1005)
at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:1)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:953)
... 34 more
谁能帮我调试一下.
Can anyone help me in debugging this.
Thanks.
推荐答案
这篇关于如何在Java中调用Oracle Sproc(使用Spring 3.0)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!