Author |
Message
|
kiran_mvr |
Posted: Mon Apr 04, 2005 8:31 am Post subject: Problems with calling a Java Method in ESQL |
|
|
Apprentice
Joined: 12 Dec 2004 Posts: 35
|
Hai ..
I tried to call a Java Method using ESQL . its of this sort..
CALL DBInsert() INTO insertStatus;
CREATE PROCEDURE DBInsert()
RETURNS CHAR
LANGUAGE JAVA
EXTERNAL NAME "Insert.FileReadAndDBInsert";
Insert is the java program name,FileReadAndDBInsert is the method in it.
I specifed the location of the Java file in classpath also. But iam getting the
following ERRORS
Error:The following error occurred during execution of an Java Method call.
Error:Java Exception calling CallStaticObjectMethodA.
Error:java.lang.NoClassDefFoundError: java/sql/Savepoint
PLZ help me with this!! very urgent... _________________ Kiran_manny |
|
Back to top |
|
 |
waugh |
Posted: Mon Apr 04, 2005 10:00 am Post subject: |
|
|
 Master
Joined: 19 Feb 2004 Posts: 225
|
Is it on windows box?
did you restart the box after you changed the classpath?
i am getting similar error.
i rebooted the server and i can run the program from command prompt.( that means its in the classpath). But broker complains class not found when deployed.
exact error:
-------------
( VENT.TESTER ) The Java Method 'Simple.addtwoints' could not be found as its containing class could not be found in the broker classpath
The specified Java Method 'Simple.addtwoints' belongs to a class that could not be found in the broker classpath. Ensure that the fully qualified name of the method is correct and that its containing class or jar file is in the broker classpath.
------------------------------------------------------
Procedure Definiton in ESQL:
CREATE PROCEDURE AddTwoIntegers(IN A INTEGER, IN B INTEGER, INOUT C INTEGER)
RETURNS INTEGER
LANGUAGE JAVA
EXTERNAL NAME "Simple.addtwoints"; |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 04, 2005 11:49 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
waugh wrote: |
Ensure that the fully qualified name of the method is correct and that its containing class or jar file is in the broker classpath. |
My emphasis. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
waugh |
Posted: Mon Apr 04, 2005 12:19 pm Post subject: |
|
|
 Master
Joined: 19 Feb 2004 Posts: 225
|
Jeff,
path to that class "C:\MQutils" was added to the classpath variable as per the documentation. restarted windows, broker. i can run that program from any directory on windows command prompt. From this i assume path is set correctly.
Simple is the java class name, addtwoints is the method name.
Java CODE:
public class Simple
{
public static int addtwoints(int A , int B, int C)
{
C = A + B;
//System.out.println("total is " + C);
return C;
}
public Simple()
{
super();
}
public static void main ( String[] aArguments )
{
Simple vSimple = new Simple();
vSimple.addtwoints(1, 2, 0);
}
}; |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 04, 2005 2:32 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'll play with it myself a little later this evening, and get back to you. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kiran_mvr |
Posted: Mon Apr 04, 2005 2:40 pm Post subject: error with calling a method in ESQL |
|
|
Apprentice
Joined: 12 Dec 2004 Posts: 35
|
Hai ,,
as you said i verified the class path and rectified it.Now the flow is working without errors but its catching some exceptions of this sort..
Exception: java.lang.SecurityException: Prohibited package name: java.sql
and iam unable to get any data in to my table which it should insert.
what shall i do now??
please guide me on this issue..
bye... _________________ Kiran_manny |
|
Back to top |
|
 |
kiran_mvr |
Posted: Mon Apr 04, 2005 2:44 pm Post subject: Problems with calling a Java Method in ESQL |
|
|
Apprentice
Joined: 12 Dec 2004 Posts: 35
|
Hai
if anyone willing to see the program i can send it.. so that i can rectifiy my errors.
bye
kiran_manny _________________ Kiran_manny |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 04, 2005 4:19 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Waugh -
I tried it. I didn't have my method signature right... I guess that using Integers in ESQL doesn't match with ints in Java.
I'm not in the mood right now to reboot my machine to pick up the changes to the class I made.
kiran_mvr -
I don't think you can make database calls from Java external procedures. Doing so runs the same risk of mangling the broker's internal transaction handling that calling out to jdbc from custom plug-ins does. And it's strongly discouraged to do so from custom plug-ins.
BUT THAT MIGHT NOT BE THE PROBLEM.
Try your java from a standalone test frame, like JUnit. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
EddieA |
Posted: Mon Apr 04, 2005 4:29 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
I guess that using Integers in ESQL doesn't match with ints in Java |
Nope:
Code: |
ESQL data types Java IN data types Java INOUT and OUT data types
INTEGER, INT java.lang.Long java.lang.Long [] |
Quote: |
I don't think you can make database calls from Java external procedures |
Not quite true:
Quote: |
Only JDBC type 4 database connections are permitted |
But don't ask me what a type 4 connection is, becasue I've got no idea.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 04, 2005 5:24 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
EddieA wrote: |
But don't ask me what a type 4 connection is, becasue I've got no idea.  |
I believe it's a "100% pure java" jdbc driver. Like the Java MQ Client API.
Edit: And, yes, I knew that it was documented how types matched between Java and ESQL. I just didn't bother to check before hand. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|