I have migrated a database from SQL Anywhere version 6 to version 12. After migrating I am facing a problem to execute a procedure which uses a Java class.

Here's the code from the procedure:

while(@@sqlstatus = 0) begin stop java
    start java
    select @something = MyQuery.c_balance(10,@num,@year)*-1

The procedure works fine in the version 6, but when I execute in version 12, it gives this error:

Could not execute statement.
Procedure 'MyQuery.c_balance' not found.
SQLCODE=-265, ODBC 3 State="42S02".

The MyQuery class is present in the database in:

External Environments/Java/Packages/MyQuery

and

External Environments/Java/All Java Classes/MyQuery

Why it does not work in the version 12? What is causing the problem and how can I fix it? Do I need to set the class path somewhere so that it can find? If yes, please tell me how can I do that.

Thanks.

asked 30 Aug '13, 05:36

sam's gravatar image

sam
315141624
accept rate: 0%


Support for Java "within" the database server was removed in ASA v9 (or was it v8?) and support for 'dot' notation to Java objects was removed at the same time.

SQL Anywhere now supports Java 'near' the database. I.e. rather than running Java procedures in-process with the database server using Sybase/iAnywhere's proprietary JRE implementation the Java procedures are now executed externally to the database server by any Java JRE implementation of your choosing (a JRE is shipped with SQL Anywhere and is the default, but you can change/upgrade it if you like). Many such 'external environments' are now supported - not only Java but also C#/DotNet, Perl, PHP, and C procedures.

So the error that you are seeing is caused by your use of the dot notation to the c_balance procedure within the MyQuery object. You need to update your database to reference the Java procedure directly. See the documentation on Java external procedures for more information.

permanent link

answered 30 Aug '13, 10:58

Mark%20Culp's gravatar image

Mark Culp
22.7k9129266
accept rate: 40%

Thanks for the answer. Could you please give a brief example on how can I update the database to reference the Java procedure correctly as you mentioned. I could not figure out from that url.

(31 Aug '13, 14:24) sam
Replies hidden

Have a look at the samples on the page Mark has linked to.

Instead of the "dot" notation you will have to use an "ordinary" SQL procedure name (say, "c_balance") for your external procedure, such as

select @something = c_balance(10,@num,@year)*-1

and need to specify the according Java class and method name (and parameter types) in the EXTERNAL NAME clause of the CREATE PROCEDURE statement, such as:

create procedure c_balance (<SQL parameter types>)
external name 'MyQuery.c_balance(<Java parameter type coding>)'
language java;
(02 Sep '13, 07:42) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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:

×64
×45
×23
×16

question asked: 30 Aug '13, 05:36

question was seen: 696 times

last updated: 02 Sep '13, 07:43