从java调用过程时无效的数据类型

时间:2014-02-17 15:12:55

标签: java oracle stored-procedures jdbc

我有2个数据库程序.. 我从java中的一个过程获取输出并将输出作为输入传递给另一个过程..

但是,在将输入传递给第二个过程时,它给出了无效的数据类型错误.Below是从中获取输出的第一个过程的定义。

PROCEDURE GET_PROJECT_DATA_PRC(PI_USER IN VARCHAR2,
PI_PROJECT_NO IN VARCHAR2,
PI_INVOICE_NUMBER IN NUMBER,
PO_PROJECT_EC_HEADER_DATA OUT TAB_TRX_HEADER_TYPE,
PO_PROJECT_EC_DETAIL_DATA OUT TAB_TRX_LINE_TYPE,
PO_PROJECT_LC_HEADER_DATA OUT TAB_TRX_HEADER_TYPE,
PO_PROJECT_LC_DETAIL_DATA OUT TAB_TRX_LINE_TYPE,
PO_PROJECT_PT_HEADER_DATA OUT TAB_TRX_HEADER_TYPE,
PO_PROJECT_PT_DETAIL_DATA OT TAB_TRX_LINE_TYPE,
PO_ERROR_CODE OUT NUMBER,
PO_ERROR_MSG OUT VARCHAR2)

下面是调用上述过程并获取输出的java代码..

Call = new SimpleJdbcCall(dataSource).withoutProcedureColumnMetaDataAccess();
Call.withCatalogName(“INV_AR_INVOCING_PKG1”);
Call.withProcedureName(“GET_PROJECT_DATA_PRC”);
Call.addDeclaredParameter(new SqlParameter(“PI_USER”,OracleTypes.VARCHAR));
Call.addDeclaredParameter(new SqlParameter(“PI_PROJECT_NO”,OracleTypes.VARCHAR));
Call.addDeclaredParameter(new SqlParameter(“PI_INVOICE_NUMBER”,OracleTypes.NUMBER));
Call.addDeclaredParameter(new      SqlParameter(“PO_PROJECT_EC_HEADER_DATA”,OracleTypes.ARRAY,”TAB_TRX_HEADER_TYPE”,new  SqlReturnType() { public Object getTypeValue(CallableStatement cs, int paramIndex,Int  sqlType, String typeName) throws SQLException { Connection connection = cs.getConnection();
Map<String, Class<?>> typeMap = connection.getTypeMap();
typeMap.put(“TAB_TRX_HEADER_TYPE”, InvoiceReviewErrorDto.class);
oracle.sql.ARRAY oraArray = (oracle.sql.ARRAY) ((weblogic.jdbc.wrapper.Array)     ((CallableStatement) cs ).getObject( paramIndex )).unwrap(ARRAY.class);
return oraArray;
}
}))
.
.
.
.
Args = new HashMap<String, Object> ();
Args.put(“PI_EC_HEADER”, out.get(“PO_PROJECT_EC_HEADER_DATA”));
Args.put(“PI_EC_LINE”, out.get(“PO_PROJECT_EC_DETAIL_DATA”));

第二个过程的定义如下:

PROCEDURE INV_MAIN_PRC(PI_EC_HEADER IN TAB_TRX_HEADER_TYPE,
PI_EC_LINE IN TAB_TRX_LINE_TYPE,
PO_EC_CUST_TRX_ID OUT RA_CUSTOMER_TRX_ALL.CUSTOMER_TRX_ID%TYPE,
PO_EC_AR_INV_NO OUT RA_CUSTOMER_TRX_ALL.TRX_NUMBER%TYPE,
PO_LC_CUST_TRX_ID OUT RA_CUSTOMER_TRX_ALL.CUSTOMER_TRX_ID%TYPE,
PO_LC_AR_INV_NO OUT RA_CUSTOMER_TRX_ALL.TRX_NUMBER%TYPE,
PO_PT_CUST_TRX_ID OUT RA_CUSTOMER_TRX_ALL.CUSTOMER_TRX_ID%TYPE,
PO_PT_AR_INV_NO OUT RA_CUSTOMER_TRX_ALL.TRX_NUMBER%TYPE,
PO_ERROR_CODE OUT NUMBER,
PO_ERROR_MSG OUT VARCHAR2);

调用第二个proc的代码如下:

This.call = new SimpleJdbcCall(dataSourceGross).withoutProcedureColumnMetaDataAccess()
.withCatalogName(“INV_AR_INVOICE_PKG”)
.withProcedureName(“INV_MAIN_PRC”)
.declareParameters(
New SqlParameter(“PI_EC_HEADER”,OracleTypes.ARRAY),
New SqlParameter(“PI_EC_LINE”,OracleTypes.ARRAY),
New SqlOutParameter(“PO_EC_CUST_TRX_ID”, OracleTypes.NUMBER),
New SqlOutParameter(“PO_EC_AR_INV_NO”, OracleTypes.VARCHAR),
New SqlOutParameter(“PO_LC_CUST_TRX_ID”, OracleTypes.NUMBER),
New SqlOutParameter(“PO_LC_AR_INV_NO”, OracleTypes.VARCHAR),
New SqlOutParameter(“PO_PT_CUST_TRX_ID”, OracleTypes.NUMBER),
New SqlOutParameter(“PO_PT_AR_INV_NO”, OracleTypes.VARCHAR),
New SqlOutParameter(DBConstants.PO_ERROR_CODE,OracleTypes.NUMBER),
New SqlOutParameter DBConstants.PO_ERROR_MSG, OracleTypes.VARCHAR));
Out = call.execute(args);

异常消息如下: org.springfamework.jdbc.BadSqlGrammarException:CallableStatementCallback;错误的SQL语法[{call INV_AR_INVOICE_PKG.INV_MAIN_PRC(?,?,?,?,?,?,?,?,?,?)}];嵌套异常是java.sql.SQLSyntaxErrorException:ORA-00902:无效的数据类型

堆栈跟踪如下:

org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL     grammar [{call INV_AR_INVOICE_PKG.INV_MAIN_PRC(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}];
nested exception is java.sql.SQLSyntaxErrorException: ORA-00902: invalid datatype at      org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubc    lassTranslator.java:94)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1030)
at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1064)
at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:388)
at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:373)
at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:177)
at com.ultimatix.dao.InvoiceReviewDAOImpl.invoicePreApprove(InvoiceReviewDAOImpl.java:678)
at com.ultimatix.service.InvoiceReviewServiceImpl.invoiceApprove(InvoiceReviewServiceImpl.java:518)
at com.ultimatix.controller.InvoiceReviewController.invoiceApprove(InvoiceReviewController.java:241)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at com.utxfrmwk.security.filter.CustomAuthenticationFilter.doFilter(CustomAuthenticationFilter.java:77)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at com.utxfrmwk.security.filter.SecurityInterceptor.doFilter(SecurityInterceptor.java:40)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

引起:java.sql.SQLSyntaxErrorException:ORA-00902:数据类型无效

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:204)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1006)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3677)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4714)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:99)
at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1066)
at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1014)

0 个答案:

没有答案