17.10 - Details About the Function of Java External Procedures - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Detailed Topics

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1184-171K
Language
English (United States)

When you write the code for an external procedure definition, you indicate that its language is Java by specifying LANGUAGE JAVA in the mandatory LANGUAGE clause (see LANGUAGE Clause).

Java external procedures execute SQL code using the standard JDBC driver interface. Because the Java external procedure is running on the database and is invoked from within a logged on session, its connection to the database is by means of a default connection named jdbc:default:connection.

Note that a Java program can create a separate connection to another database, or to the same database (by means of another session to be logged onto). If an external Java procedure does this, its actions can create an undetectable deadlock.

The ANSI SQL:2011 standard specifies the following set of rules for a Java external procedure.
  • You must compile the Java source code outside the database.

    The external Java language routine must be written using the JDBC standard for coding embedded SQL statements in a Java program.

    The resulting class or classes (the byte code) must be placed in a JAR file.

  • You must then register the JAR file with the database.
  • To do this, you call an external procedure named SQLJ.Install_Jar.
  • The system creates the Java external procedure using its EXTERNAL NAME clause, which specifies the registered JAR file and its associated Java class.

Once it has been created, you can access the Java routine in the same manner as any external procedure.

See Teradata Vantage™ - SQL External Routine Programming, B035-1147 for information on writing Java external procedures.