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/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.
asked 30 Aug '13, 05:36
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.
answered 30 Aug '13, 10:58