SQL/JRT

Last updated

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". SQL/JRT 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.)

Contents

Example

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

CREATEFUNCTIONsinh(vDOUBLE)RETURNSDOUBLELANGUAGEJAVADETERMINISTICNOSQLEXTERNALNAME'CLASSPATH:java.lang.Math.sinh'SELECTsinh(doublecolumn)FROMmytable

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]

Implementations

SQL/JRT stored procedures are implemented in HSQLDB. [1] Java stored procedures have also been implemented in Oracle's JServer (or Aurora JVM), which was introduced in the Oracle Database version 8i in 1999; [2] [3] it is now called Oracle JVM. [4] IBM DB2 also supported Java stored procedures since about 1998, although using an external JVM (at that time). [5]

See also

Related Research Articles

SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e. data incorporating relations among entities and variables.

A stored procedure is a subroutine available to applications that access a relational database management system (RDBMS). Such procedures are stored in the database data dictionary.

Transact-SQL (T-SQL) is Microsoft's and Sybase's proprietary extension to the SQL used to interact with relational databases. T-SQL expands on the SQL standard to include procedural programming, local variables, various support functions for string processing, date processing, mathematics, etc. and changes to the DELETE and UPDATE statements.

HSQLDB

HSQLDB is a relational database management system written in Java. It has a JDBC driver and supports a large subset of SQL-92, SQL:2008, and SQL:2011 standards. It offers a fast, small database engine which offers both in-memory and disk-based tables. Both embedded and server modes are available.

PL/pgSQL procedural programming language

PL/pgSQL is a procedural programming language supported by the PostgreSQL ORDBMS. It closely resembles Oracle's PL/SQL language. Implemented by Jan Wieck, PL/pgSQL first appeared with PostgreSQL 6.4, released on October 30, 1998. Version 9 also implements some ISO SQL/PSM features, like overloading of SQL-invoked functions and procedures.

The following tables compare general and technical information for a number of relational database management systems. Please see the individual products' articles for further information. Unless otherwise specified in footnotes, comparisons are based on the stable versions without any add-ons, extensions or external programs.

A user-defined function (UDF) is a function provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment.

Oracle Spatial and Graph, formerly Oracle Spatial, forms a separately-licensed option component of the Oracle Database. The spatial features in Oracle Spatial and Graph aid users in managing geographic and location-data in a native type within an Oracle database, potentially supporting a wide range of applications — from automated mapping, facilities management, and geographic information systems (AM/FM/GIS), to wireless location services and location-enabled e-business. The graph features in Oracle Spatial and Graph include Oracle Network Data Model (NDM) graphs used in traditional network applications in major transportation, telcos, utilities and energy organizations and RDF semantic graphs used in social networks and social interactions and in linking disparate data sets to address requirements from the research, health sciences, finance, media and intelligence communities.

SQLJ is a working title for efforts to combine Java and SQL. It was a common effort started around 1997 by engineers from IBM, Oracle, Compaq, Informix, Sybase, Cloudscape and Sun Microsystems.

The SQuirreL SQL Client is a database administration tool. It uses JDBC to allow users to explore and interact with databases via a JDBC driver. It provides an editor that offers code completion and syntax highlighting for standard SQL. It also provides a plugin architecture that allows plugin writers to modify much of the application's behavior to provide database-specific functionality or features that are database-independent. As this desktop application is written entirely in Java with Swing UI components, it should run on any platform that has a JVM.

SQL/PSM is an ISO standard mainly defining an extension of SQL with a procedural language for use in stored procedures. Initially published in 1996 as an extension of SQL-92, SQL/PSM was later incorporated into the multi-part SQL:1999 standard, and has been part 4 of that standard since then, most recently in SQL:2016. The SQL:1999 part 4 covered less than the original PSM-96 because the SQL statements for defining, managing, and invoking routines were actually incorporated into part 2 SQL/Foundation, leaving only the procedural language itself as SQL/PSM. The SQL/PSM facilities are still optional as far as the SQL standard is concerned; most of them are grouped in Features P001-P008.

SQL/OLB, or Object Language Bindings, is a standard for embedding SQL in Java, commonly known by its prior name as SQLJ. Besides describing the syntax and semantics of SQLJ, which are typically given relative to JDBC, the standard also describes mechanisms to ensure binary portability of SQLJ applications, and specifies various Java packages and their contained classes.

SQL:1999 was the fourth revision of the SQL database query language. It introduced many new features, many of which required clarifications in the subsequent SQL:2003. In the meanwhile SQL:1999 is deprecated.

Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation. It provides methods to query and update data in a database, and is oriented toward relational databases. A JDBC-to-ODBC bridge enables connections to any ODBC-accessible data source in the Java virtual machine (JVM) host environment.

In database management systems (DBMS), a prepared statement or parameterized statement is a feature used to execute the same or similar database statements repeatedly with high efficiency. Typically used with SQL statements such as queries or updates, the prepared statement takes the form of a template into which certain constant values are substituted during each execution.

PL/SQL is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database, Times Ten in-memory database, and IBM DB 2. Oracle Corporation usually extends PL/SQL functionality with each successive release of the Oracle Database.

Object-PL/SQL is a methodology of using the Oracle Corporation's procedural extension language for SQL and the Oracle relational database. The additional features from version 7 and other improvements, lead to one of the large-scale environment implementations of the object-oriented database paradigm.

The SQL:1999 standard introduced a number of object-relational database features into SQL, chiefly among them structured user-defined types, usually called just structured types. These can be defined either in plain SQL with CREATE TYPE but also in Java via SQL/JRT. SQL structured types allow single inheritance.

In relational databases a virtual column is a table column whose value is automatically computed using other columns values, or another deterministic expression. Virtual columns are defined of SQL:2003 as Generated Column, and are only implemented by some DBMSs, like MariaDB, SQL Server, Oracle, SQLite and Firebird.

References

  1. 1 2 3 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.
  5. Don Chamberlin (1998). A Complete Guide to DB2 Universal Database. Morgan Kaufmann. p. 565. ISBN   978-1-55860-482-7 . Retrieved 16 November 2012.