on 2012 Dec 10 11:48 AM
Hi, I'm working on trying to get the Invoice class from the Java in the Database examples to work. I'm following this guide: http://dcx.sybase.com/1200/en/dbprogramming/pg-java-fields.html
When I try to call the stored procedure (step 2 from that guide), I get this error:
Could not execute statement. Procedure 'init' terminated with unhandled exception 'java.lang.NoSuchMethodException: Invoice.init(java.lang.String, double, java.lang.String, double)' SQLCODE=-91, ODBC 3 State="HY000" Line 1, column 1 You can continue executing or stop. CALL init('Shirt',10.00,'Jacket',25.00)
This error would indicate that I somehow installed the Invoice class wrong, yet when I go to Sybase Central > External Environments > Java > All Java Classes I can clearly see the Invoice class listed there. In addition, when I double click on the Invoice class, I can clearly see the method signature for the init function along with all the other functions. This is what I see:
public class Invoice extends java.lang.Object { //Properties public static java.lang.String lineItem1Description; public static double lineItem1Cost; public static java.lang.String lineItem2Description; public static double lineItem2Cost; //Constructors public Invoice(); //Methods public static double totalSum(); public static double rateOfTaxation(); public static java.lang.String getLineItem1Description(); public static double getLineItem1Cost(); public static java.lang.String getLineItem2Description(); public static double getLineItem2Cost(); public static void init(java.lang.String, double, java.lang.String, double); }
How can it be giving me an error that no such method exists when I can clearly see the method, with a matching signature inside the DB? What am I doing wrong?
I'm on ASA 12 if that helps. Thank you!
Request clarification before answering.
Hey, I fixed it! The problem was that the CLASSPATH environment variable wasn't set. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not understand your solution. If you properly installed the JAVA class in the database, then you should not be putting anything in the CLASSPATH. Putting the classes/jars in the classpath will force the classes to be loaded by the system classloader which is not what you want. Please consider undoing your change, rerunning your repro to cause the error and then looking at the server window to see what the stack trace leading to the classnotfound exception is. That will give you and us a better idea of what went wrong.
User | Count |
---|---|
87 | |
10 | |
9 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.