Jump to content

SQL/JRT

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Tijfo098 (talk | contribs) at 21:05, 15 November 2012. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The SQL/JRT, or SQL Routines and Types for the Java Programming Language, is an extension to the SQL standard first published as ISO/IEC 9075-13:2002 (part 13 of SQL:1999). SQL/JRT specifies the ability to invoke static Java methods as routines from within SQL applications, commonly referred to as "Java stored procedures". It also calls for the ability to use Java classes as SQL structured user-defined types. The two parts of the extension originate from the earlier ANSI SQLJ part 1 and 2 standards (not to be confused with SQLJ part 0, which defined an embedding of SQL into Java, later standardized by ISO as SQL/OLB.)

SQL/JRT is implemented in HSQLDB[1]. A similar feature called JServer (or Aurora JVM) was introduced in the Oracle Database version 8i in 1999.[2][3] It is now called Oracle JVM.[4]

Example

SQL/JRT allows a Java function to be called from SQL code like this[1]:

CREATE FUNCTION sinh(v DOUBLE) RETURNS DOUBLE
  LANGUAGE JAVA DETERMINISTIC NO SQL
  EXTERNAL NAME 'CLASSPATH:java.lang.Math.sinh'

SELECT sinh(doublecolumn) FROM mytable

SQL/JRT also allows Java code to dynamically generate tables using a java.sql.ResultSet object. The result sets returned are converted to SQL tables and can be used anywhere a table or view can be used[1].

See also

References

  1. ^ a b c HSQLDB manual
  2. ^ Bulusu Lakshman (2002). Oracle & Java Development. Sams Publishing. p. 6. ISBN 978-0-672-32117-7.
  3. ^ The Aurora JVM and Its Components, Oracle Corp.
  4. ^ Rick Greenwald; Robert Stackowiak; Jonathan Stern (2008). Oracle Essentials: Oracle Database 11g. O'Reilly Media, Inc. p. 323. ISBN 978-0-596-51454-9.