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
    public static java.lang.String lineItem1Description;
    public static double lineItem1Cost;
    public static java.lang.String lineItem2Description;
    public static double lineItem2Cost;

    public Invoice();

    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!

asked 10 Dec '12, 11:48

glitch003's gravatar image

accept rate: 0%

Hey, I fixed it! The problem was that the CLASSPATH environment variable wasn't set. Thanks!

permanent link

answered 10 Dec '12, 11:54

glitch003's gravatar image

accept rate: 0%

Could you post what you did, so anyone else with the same problem could fix it to? Thanks!

(12 Dec '12, 08:56) Jonathan Baker

Sure, I simply set the CLASSPATH environment variable to include the Java Runtime Environment directory, and the path to my classes.. I delimited the two paths with a semicolon.

(12 Dec '12, 10:07) glitch003

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.

(12 Dec '12, 10:32) Karim Khamis
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 Dec '12, 11:48

question was seen: 1,398 times

last updated: 12 Dec '12, 10:32