未分类SQL的SQLException

时间:2014-06-03 11:49:15

标签: java spring jdbc spring-integration spring-jdbc

我在项目中使用Spring Integration。 根据我的要求,我必须同时调用两个存储过程。这是我的代码:     

    <int:service-activator ref="msgHandler" method="buildRequestBasedDataSource" />

    <int-jdbc:stored-proc-outbound-gateway
                    id="PQIssueHistory-StoredProcedure-PQCOMMENTLOOKUP"
                    auto-startup="true"
                    data-source="routingDataSource"
                    stored-procedure-name="${PQIssueHistory-StoredProcedure-PQCOMMENTLOOKUP}"
                    skip-undeclared-results="true"
                    ignore-column-meta-data="true"  
                    use-payload-as-parameter-source = "false"
                    expect-single-result="true" >

                            <int-jdbc:sql-parameter-definition name="P_CRDATTIM" direction="IN" type="VARCHAR" />
                            <int-jdbc:sql-parameter-definition name="P_RECORDCD" direction="IN" type="VARCHAR" />
                            <int-jdbc:sql-parameter-definition name="P_CRNODE" direction="IN" type="VARCHAR" />

                            <int-jdbc:parameter name="P_CRDATTIM" expression="#xpath(payload, '//CRDATTIM')" />
                            <int-jdbc:parameter name="P_RECORDCD" expression="#xpath(payload, '//RECORDCD')" />
                            <int-jdbc:parameter name="P_CRNODE" expression="#xpath(payload, '//CRNODE')" />

            <int-jdbc:returning-resultset name="rowMapper" row-mapper="com.dsths.cs.awd.utils.ResultSetRowMapper"/>

    </int-jdbc:stored-proc-outbound-gateway>

    <int:service-activator ref="msgHandler"  method="buildMessageFromExtSysResponseTestOne" />

    <int:header-enricher default-overwrite="true"  should-skip-nulls="true"  >
        <int:header name="${headerNames.originalPayload}" expression="payload" />  
    </int:header-enricher>    



</int:chain>    

    <int:channel id="test" />
<int:chain input-channel="test"  output-channel="PQIssueHistory-XsltTransformInputChannel" >

<int-jdbc:stored-proc-outbound-gateway
                    id="PQIssueHistory-StoredProcedure-PQHISTORYLOOKUP"
                    auto-startup="true"
                    data-source="routingDataSource"
                    stored-procedure-name="${PQIssueHistory-StoredProcedure-PQHISTORYLOOKUP}"
                    skip-undeclared-results="true"
                    ignore-column-meta-data="true"  
                    use-payload-as-parameter-source = "false"
                    expect-single-result="true" >

                            <int-jdbc:sql-parameter-definition name="P_CRDATTIM" direction="IN" type="VARCHAR" />
                            <int-jdbc:sql-parameter-definition name="P_RECORDCD" direction="IN" type="VARCHAR" />
                            <int-jdbc:sql-parameter-definition name="P_CRNODE" direction="IN" type="VARCHAR" />

                            <int-jdbc:parameter name="P_CRDATTIM" expression="#xpath(payload, '//CRDATTIM')" />
                            <int-jdbc:parameter name="P_RECORDCD" expression="#xpath(payload, '//RECORDCD')" />
                            <int-jdbc:parameter name="P_CRNODE" expression="#xpath(payload, '//CRNODE')" />

            <int-jdbc:returning-resultset name="rowMapper" row-mapper="com.dsths.cs.awd.utils.ResultSetRowMapper"/>

    </int-jdbc:stored-proc-outbound-gateway>

<int:service-activator ref="msgHandler"  method="buildMessageFromExtSysResponseTestTwo" />

</int:chain>

当我使用junit测试用例执行时,我能够毫无问题地点击存储过程。但是,当我尝试从GUI执行时(即在与UI集成之后),我收到以下错误:< / p>

org.springframework.integration.MessageHandlingException: error occurred in message handler [org.springframework.integration.handler.MessageHandlerChain#201$child.PQIssueHistory-StoredProcedure-PQHISTORYLOOKUP.handler]
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:79)
    at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:131)
   ................................
............................
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call ZSPPQHISTORYLOOKUP(?, ?, ?)}]; SQL state [000RZ]; error code [930027]; No record found in the VOC file for "BP". ; nested exception is java.sql.SQLException: No record found in the VOC file for "BP".
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    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:1036)
    at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1070)
    at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:387)
    at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:350)
    at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:181)
    at org.springframework.integration.jdbc.StoredProcExecutor.executeStoredProcedure(StoredProcExecutor.java:335)
    at org.springframework.integration.jdbc.StoredProcExecutor.executeStoredProcedureInternal(StoredProcExecutor.java:325)
    at org.springframework.integration.jdbc.StoredProcExecutor.executeStoredProcedure(StoredProcExecutor.java:294)
    at org.springframework.integration.jdbc.StoredProcOutboundGateway.handleRequestMessage(StoredProcOutboundGateway.java:56)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:142)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
    ... 146 more
Caused by: java.sql.SQLException: No record found in the VOC file for "BP".
    at com.ibm.u2.jdbc.UniJDBCMsgFactory.createException(UniJDBCMsgFactory.java:101)
    at com.ibm.u2.jdbc.UniJDBCExceptionSupport.addException(UniJDBCExceptionSupport.java:87)
    at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.addServerError(UniJDBCProtocolU2Impl.java:2799)
    at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.serverExecuteSql(UniJDBCProtocolU2Impl.java:2130)
    at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.executeSql(UniJDBCProtocolU2Impl.java:2169)
    at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.doExecute(UniJDBCProtocolU2Impl.java:2208)
    at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.executeStatementQuery(UniJDBCProtocolU2Impl.java:606)
    at com.ibm.u2.jdbc.UniJDBCPreparedStatementImpl.execute(UniJDBCPreparedStatementImpl.java:407)
    at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:299)
    at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1072)
    at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1070)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1020)
    ... 156 more
12:26:25,972 INFO  [STDOUT] 12:26:25,971 DEBUG [org.springframework.integration.channel.DirectChannel.preSend] preSend on channel 'cs-exceptionHandlingChannel', message: [Payload=org.springframework.integration.MessageHandlingException: error occurred in message handler [org.springframework.integration.handler.MessageHandlerChain#201$child.PQIssueHistory-StoredProcedure-PQHISTORYLOOKUP.handler]][Headers={timestamp=1401778585971, id=60a1966f-e5ed-8bc0-d9d0-76ee7f6856d8, errorChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@1c8968f, replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@1c8968f}]

从上面的例外情况可以看出,控件将进入错误通道。在这里,我只是想知道导致问题的sql查询。我打开了“DEBUG”。如果任何人可以分享他们关于如何进一步寻找/修复问题的想法,那就太棒了。

2 个答案:

答案 0 :(得分:1)

阿肖克,我只能分享想法,因为我可能知道更少的springjdbc。但我认为导致问题的原因是驱动程序添加了一个声明,例如getUpdateCount。

首先,您可以创建一个类来扩展JdbcTemplate,但是复制所有内容并更改构造函数,使其与JdbcTemplate相同。我假设您可以看到JdbcTemplate的源代码。

其次,在第1020行,找出它是什么以及如何调用它。该异常从SQLException转换为您未向我们展示的其他内容。请告诉我们,我们知道顶级例外是什么。你使用的是什么版本的springjdbc?

第三,现在您可以修改代码以使用您自己的子类而不是JdbcTemlate,您可以修改代码。评论像警告一样的东西。您一步一步地从try {}块中的最后一行进行注释,其中异常被捕获并逐个进行。然后你应该能够找出驱动程序添加的额外SQL语句导致问题。

这只是一个想法。请告诉我们您的结果,我们可以继续。

答案 1 :(得分:0)

如果您的意思是想要查看发送到数据库的查询的实际内容,请使用间谍驱动程序;只是谷歌;有很多。或者使用WireShark或类似方法获取网络跟踪。