Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - Programming » Java in the database » Java support in SQL Anywhere » Java in the database Q & A


How do I access Java from SQL?

You can treat Java methods as stored procedures, which can be called from SQL.

You must create a stored procedure that runs your method. For example:

EXTERNAL NAME 'JDBCExample.MyMethod ()V' 

For more information, see CREATE PROCEDURE statement (web services).

For example, the SQL function PI( * ) returns the value for pi. The Java API class java.lang.Math has a parallel field named PI returning the same value. But java.lang.Math also has a field named E that returns the base of the natural logarithms, and a method that computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.

Other members of the Java API offer even more specialized functionality. For example, java.util.Stack generates a last-in, first-out queue that can store ordered lists; java.util.HashTable maps values to keys; and java.util.StringTokenizer breaks a string of characters into individual word units.