You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Kevin Sutter (JIRA)" <ji...@apache.org> on 2012/06/12 15:51:42 UTC

[jira] [Commented] (OPENJPA-2210) Method executeQuery cannot be used for update. ERRORCODE=-4476, SQLSTATE=null

    [ https://issues.apache.org/jira/browse/OPENJPA-2210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13293624#comment-13293624 ] 

Kevin Sutter commented on OPENJPA-2210:
---------------------------------------

When I searched on your ErrorCode, I hit the following explanation for DB2:  http://www-304.ibm.com/support/docview.wss?uid=swg1IC64831
This basically says that this ErrorCode can be returned for an empty result set.  So, I would first check whether your SQL would produce any results.  It sounds like there's a DB2 property that can set to return an empty result set instead of throwing this exception.

If this is not your issue, then I'd look further down the call stack to determine the entry point in your application code to determine exactly which statement is being executed.  For example, maybe it's not complaining about this native query, but some other sql statement that is actually an "update".

Since it looks like you are a WebSphere customer, I would also suggest opening a PMR.  This issue could easily span across other components (DB2, WebSphere, OpenJPA, etc).  A PMR will be able to span these mulitple disciplines and get you to the right solution (if my suggestions above don't do the trick).  Good luck!
                
>  Method executeQuery cannot be used for update. ERRORCODE=-4476, SQLSTATE=null
> ------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2210
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2210
>             Project: OpenJPA
>          Issue Type: Question
>          Components: jdbc, jpa
>    Affects Versions: 1.0.0
>         Environment: Windows 7, 64 bit operating system , RAD - 8.0.4, WAS 7.0, db2jcc4.jar, 
>            Reporter: Sathish
>            Priority: Critical
>              Labels: newbie
>
> I am using OpenJPA 1.x to persist the datas using the Application Server WAS 7.0. Now I created a 'named-native-sql' to perform a join operation and its corresponding sql-result set mapping in my orm.xml to get the records. THe configuration is as follows
> 		<named-native-query name="getPaymentById" result-set-mapping="sql_result">
> 			<query>SELECT T1.*, T2.*, T3.* FROM SSP.PMNT T1 LEFT JOIN SSP.PMNT_REF T2 ON T1.PYMT_ID = T2.PYMT_ID LEFT JOIN SSP.RMRK T3 ON T1.PYMT_ID = T3.PYMT_ID WHERE T1.PYMT_ID = 8 
> 			</query>
> 		</named-native-query>		
> 		<sql-result-set-mapping name="sql_result">
> 			<entity-result entity-class="Payment"></entity-result>
> 			<entity-result entity-class="PaymentReference"></entity-result>
> 			<entity-result entity-class="Remark"></entity-result>
> 		</sql-result-set-mapping>
> Now when the application runs i am getting the following exception
> Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][10103][10941][3.58.81] Method executeQuery cannot be used for update. ERRORCODE=-4476, SQLSTATE=null
> at com.ibm.db2.jcc.am.ed.a(ed.java:660)
> at com.ibm.db2.jcc.am.ed.a(ed.java:60)
> at com.ibm.db2.jcc.am.ed.a(ed.java:120)
> at com.ibm.db2.jcc.am.tm.a(tm.java:3945)
> at com.ibm.db2.jcc.am.um.b(um.java:3455)
> at com.ibm.db2.jcc.am.vm.Zb(vm.java:144)
> at com.ibm.db2.jcc.am.vm.executeQuery(vm.java:127)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:1105)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:726)
> Please let me know what could be the error and how to resolve it. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira