15.00 - Details About the Function of Java External Procedures - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1184-015K

Details About the Function of Java External Procedures

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” on page 429).

Java external procedures execute SQL code using the standard JDBC driver interface. Because the Java external procedure is running on the Teradata 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 SQL External Routine Programming for information on writing Java external procedures.