title: WSO2 Data service not working for named queries (prepare statements)
body: <p>I was just trying to do a simple data service connecting to HR schema on Oracle XE DB. I just wrote a simple query with operation which takes an input parameter and gets the result accordingly as per the bind data passed.</p>
  
  <p>My Query looks as below</p>
  
  <pre><code>SELECT first_name,last_name,email,phone_number,hire_date,salary 
  FROM employees 
  WHERE first_name like :Bind_name
  </code></pre>
  
  <p>I have added a input variable Bind_name and passing it when im requesting the service.</p>
  
  <p>But, when i trigger the service i see below error and couldn't find relevant help on web.</p>
  
  <pre><code>[2012-06-13 12:42:08,101] ERROR {org.wso2.carbon.dataservices.core.description.query.SQLQuery} -  org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
  java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.setStringValue(SQLQuery.java:1943)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.setParamInPreparedStatement(SQLQuery.java:1411)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.createProcessedPreparedStatement(SQLQuery.java:1380)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.processNormalQuery(SQLQuery.java:802)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.runQuery(SQLQuery.java:2069)
      at org.wso2.carbon.dataservices.core.description.query.Query.execute(Query.java:252)
      at org.wso2.carbon.dataservices.core.engine.CallQuery.execute(CallQuery.java:185)
      at org.wso2.carbon.dataservices.core.engine.CallQueryGroup.execute(CallQueryGroup.java:110)
      at org.wso2.carbon.dataservices.core.description.operation.Operation.execute(Operation.java:71)
      at org.wso2.carbon.dataservices.core.engine.DataService.invoke(DataService.java:592)
      at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:99)
      at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:110)
      at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
      at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:563)
      at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)
      at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
      at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
      at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
      at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:409)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:286)
      at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
      at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)
      at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
      at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
      at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
      at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:199)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:164)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.wso2.carbon.server.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:154)
      at org.wso2.carbon.server.TomcatServer$1.invoke(TomcatServer.java:254)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
      at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:356)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  [2012-06-13 12:42:08,106] ERROR {org.wso2.carbon.dataservices.core.engine.DataService} -  DS Fault Message: Error in 'SQLQuery.processNormalQuery'
  DS Code: DATABASE_ERROR
  Source Data Service:-
  Name: EmployeeService
  Location: \EmployeeService.dbs
  Description: N/A
  Default Namespace: http://ws.wso2.org/dataservice
  Current Request Name: findByEmployeeNameLike
  Current Params: {Bind_name=S%}
  Nested Exception:-
  java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
  
  DS Fault Message: Error in 'SQLQuery.processNormalQuery'
  DS Code: DATABASE_ERROR
  Source Data Service:-
  Name: EmployeeService
  Location: \EmployeeService.dbs
  Description: N/A
  Default Namespace: http://ws.wso2.org/dataservice
  Current Request Name: findByEmployeeNameLike
  Current Params: {Bind_name=S%}
  Nested Exception:-
  java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
  
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.processNormalQuery(SQLQuery.java:844)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.runQuery(SQLQuery.java:2069)
      at org.wso2.carbon.dataservices.core.description.query.Query.execute(Query.java:252)
      at org.wso2.carbon.dataservices.core.engine.CallQuery.execute(CallQuery.java:185)
      at org.wso2.carbon.dataservices.core.engine.CallQueryGroup.execute(CallQueryGroup.java:110)
      at org.wso2.carbon.dataservices.core.description.operation.Operation.execute(Operation.java:71)
      at org.wso2.carbon.dataservices.core.engine.DataService.invoke(DataService.java:592)
      at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:99)
      at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:110)
      at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
      at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:563)
      at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)
      at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
      at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
      at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
      at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:409)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:286)
      at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
      at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)
      at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
      at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
      at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
      at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:199)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:164)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.wso2.carbon.server.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:154)
      at org.wso2.carbon.server.TomcatServer$1.invoke(TomcatServer.java:254)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
      at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:356)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.setStringValue(SQLQuery.java:1943)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.setParamInPreparedStatement(SQLQuery.java:1411)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.createProcessedPreparedStatement(SQLQuery.java:1380)
      at org.wso2.carbon.dataservices.core.description.query.SQLQuery.processNormalQuery(SQLQuery.java:802)
      ... 50 more
  [2012-06-13 12:42:08,110] ERROR {org.apache.axis2.transport.http.CommonsHTTPTransportSender} -  DS Fault Message: Error in 'SQLQuery.processNormalQuery'
  DS Code: DATABASE_ERROR
  Source Data Service:-
  Name: EmployeeService
  Location: \EmployeeService.dbs
  Description: N/A
  Default Namespace: http://ws.wso2.org/dataservice
  Current Request Name: findByEmployeeNameLike
  Current Params: {Bind_name=S%}
  Nested Exception:-
  java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
  
  org.apache.axis2.AxisFault: DS Fault Message: Error in 'SQLQuery.processNormalQuery'
  DS Code: DATABASE_ERROR
  Source Data Service:-
  Name: EmployeeService
  Location: \EmployeeService.dbs
  Description: N/A
  Default Namespace: http://ws.wso2.org/dataservice
  Current Request Name: findByEmployeeNameLike
  Current Params: {Bind_name=S%}
  Nested Exception:-
  java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
  
      at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
      at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:78)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:409)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:286)
      at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
      at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)
      at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
      at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
      at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
      at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:199)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:164)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.wso2.carbon.server.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:154)
      at org.wso2.carbon.server.TomcatServer$1.invoke(TomcatServer.java:254)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
      at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:356)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processNormalQuery'
  DS Code: DATABASE_ERROR
  Source Data Service:-
  Name: EmployeeService
  Location: \EmployeeService.dbs
  Description: N/A
  Default Namespace: http://ws.wso2.org/dataservice
  Current Request Name: findByEmployeeNameLike
  Current Params: {Bind_name=S%}
  Nested Exception:-
  java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingPreparedStatement cannot be cast to java.sql.CallableStatement
  
      at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:105)
      at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:110)
      at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
      at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:563)
      at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)
      at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
      at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
      at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
      at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
      ... 35 more
  </code></pre>