Author |
Message
|
nmaddisetti |
Posted: Sat Mar 25, 2006 4:33 am Post subject: Problem in calling java method |
|
|
Centurion
Joined: 06 Oct 2004 Posts: 145
|
Hi,
I am using MB 6.0.
I am calling a java method and it returns Double[] from java method
in ESQL prcedure iam using return type as FLOAT then it is giveng me exception as ESQL and JAVA return type mismatch
and if i am using INOUT parameter it is working fine
what might be the problem.
Thanks,
nmaddisetti. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Mar 25, 2006 5:11 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Working as designed. You need to pass the parms as reference. Anyway I doubt very much that a float would match a double[]. This should blow up somewhere else.
If ESQL Float matches java double (to be verified) then at the least you should try Float[] as your return is double[].
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jbanoop |
Posted: Sat Mar 25, 2006 6:37 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
* ESQL FLOAT can be passed in as INOUT parameter and its counterpart in java is java.lang.Double[] (yes a Double[] i dont know the reason but so it says in the documentation and it works as well).
* When using the RETURNS FLOAT in the procedure definition in ESQL, the counterpart in java seems to be java.lang.Double. (more like it but wonder why the difference).
ESQL data types Java IN data types Java INOUT/OUT data types
FLOAT java.lang.Double java.lang.Double[]
The document seems to be silent on whether the return type is treated as IN or OUT or whatever ..
Hope this helps. |
|
Back to top |
|
 |
mgk |
Posted: Sat Mar 25, 2006 7:36 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi,
The return datatype cannot be an Array. This is mentioned in the docs. _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
jbanoop |
Posted: Sat Mar 25, 2006 10:19 pm Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
Hi Mgk,
Is there any reason why for INOUT parameters the mapping between a singular FLOAT type in ESQL becomes an array (java.lang.Double[]) in java. just curious.
Regards,
Anoop |
|
Back to top |
|
 |
mgk |
Posted: Sun Mar 26, 2006 8:45 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Well all the ESQL Datatypes allow values to be NULL, whereas non of the Java primatives can be NULL. Therefore, IN datatypes require the Java 'Object Wrappers' (java.lang.Integer etc) to be used. In the case of INOUT and OUT datatypes, in addition to having to allow NULL, ESQL allows the actual values passed to a method can be changed inside that method. But because of the way Java passes parameters to methods, you cannot change an object passed into a method and have the caller see that change. However, with an array you can change the members inside the array and the caller can see the changes you made. Hence the need for the use of single element arrays to support INOUT and OUT parameters.
Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
jbanoop |
Posted: Mon Mar 27, 2006 2:37 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
Thanks mgk. Got it.
Anoop |
|
Back to top |
|
 |
vmurali_au |
Posted: Thu Aug 16, 2007 1:12 pm Post subject: |
|
|
 Voyager
Joined: 26 Mar 2004 Posts: 76
|
I dont get it.
I'm trying to pass some 2 OUT parameters to java method and set the value for those params inside the method.
Code: |
DECLARE var1 CHARACTER;
DECLARE var2 BLOB;
CALL javaProc(var1, var2); |
javaProc is defined as
Code: |
javaProc(OUT var1, OUT var2) |
Code: |
static void javaProc(String[] var1, byte[][] var2)
{
var1 = new String[]{"THIS IS A TEST"};
var2 = new byte[][]{"THIS IS A TEST".getBytes()};
} |
When the above method returns i dont see the value of var1 & var2 to be populated in the ESQL code.
Am i doing something wrong here? |
|
Back to top |
|
 |
vmurali_au |
Posted: Fri Aug 17, 2007 1:54 pm Post subject: |
|
|
 Voyager
Joined: 26 Mar 2004 Posts: 76
|
|
Back to top |
|
 |
vmurali_au |
Posted: Wed Aug 22, 2007 12:08 pm Post subject: |
|
|
 Voyager
Joined: 26 Mar 2004 Posts: 76
|
Can someone let me know how to populate the value for a IN variable in a java procedure and send the result out to the ESQL code.
Thanks in Advance. |
|
Back to top |
|
 |
|