Bug 1044786

Summary: Error when calling DB2 9.7 Stored Procedure on SQL Binding
Product: [JBoss] JBoss Fuse Service Works 6 Reporter: Thiago Araki <taraki>
Component: Camel, SwitchYardAssignee: Nobody <nobody>
Status: NEW --- QA Contact: Matej Melko <mmelko>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: aaroncirillo, aileenc, atangrin, ganandan, kejohnso, soa-p-jira, tasato
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
The org.apache.camel.component.sql.SQLProducer class is not able to differentiate an SQL select statement from a procedure call, and then it always creates a PreparedStatement instead of CallableStatement. If you are using DB2, this results in an org.switchyard.SwitchYardException.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Thiago Araki 2013-12-19 02:14:49 UTC
Description of problem:
Error occurs while executing the following Service:

<sql:binding.sql name="sql1" initialDelay="1000" period="1s">
    <sql:query>call avg_sal('M',?)</sql:query>
   <sql:dataSourceRef>java:jboss/viavarejodb2</sql:dataSourceRef>
</sql:binding.sql>

The Stored Procedure "call avg_sal('M',?)" works if I call from a Java Bean Implementation.

Version-Release number of selected component (if applicable):
Fuse SweviceWorks 6.0 ER7

How reproducible:
Happens every time. Easy to reproduce.

Steps to Reproduce:
1. Create a SQL Binding Service 
2. Populate "query" field with a Stored Procedure call
3. Execute the project

Actual results:
Caused by: org.switchyard.SwitchYardException: org.apache.camel.FailedToCreateRouteException: Failed to create route V1CamelSqlBindingModel/DatabaseService@sql1#-423328149 at: >>> To[sql://call%20avg_sal('M',?)?dataSourceRef=java:jboss/viavarejodb2] <<< in route: Route[[From[timer://V1CamelSqlBindingModel/DatabaseService@s... because of Failed to resolve endpoint: sql://call%20avg_sal('M',?%29%3FdataSourceRef=java%3Ajboss%2Fviavarejodb2 due to: Property 'dataSource' is required

Expected results:
Receive Stored Procedure Result Set

Additional info:

Comment 2 Thiago Araki 2013-12-19 03:44:13 UTC
The org.apache.camel.component.sql.SQLProducer class is not able to differentiate from SQL select statement to a Procedure Call, and then it always creates a PreparedStatement instead of CallableStatement.

In DB2 driver, the following exception is correctly raised for this situation:

Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=JTRACH.A1S002;PROCEDURE, DRIVER=4.16.53 

As a fix, I would propose a new property in Camel SQL to distinguish between queries and functions/procedures calls.

Comment 4 Keith Babo 2013-12-20 00:35:00 UTC
Agree.  If this is implemented upstream in Apache Camel, then we can pull it down in the next refresh of Camel in a future product release.

Comment 5 Tadayoshi Sato 2014-01-10 01:56:22 UTC
The relevant Camel RFE seems to be: https://issues.apache.org/jira/browse/CAMEL-4725

Comment 6 Aaron Cirillo 2014-06-26 19:19:20 UTC
(In reply to Tadayoshi Sato from comment #5)
> The relevant Camel RFE seems to be:
> https://issues.apache.org/jira/browse/CAMEL-4725

Comment 8 Aileen 2015-02-16 16:56:01 UTC
No response from customer.