IMPORT CLASS

Documentation

VoltDB Home » Documentation » Using VoltDB

IMPORT CLASS

IMPORT CLASS — Specifies additional Java classes to include in the application catalog.

Synopsis

IMPORT CLASS class-name

Description

The IMPORT CLASS statement lets you specify class files to be added to the application catalog when the schema is compiled. You can include individual class files only; the IMPORT CLASS statement does not extract classes from JAR files. However, you can use Ant-style wildcards in the class specification to include multiple classes. For example:

IMPORT CLASS org.mycompany.utils.*;

Use the IMPORT CLASS statement to include reusable code that is accessed by multiple stored procedures. Any classes and methods called by stored procedures must follow the same rules for deterministic behavior that stored procedures follow, as described in Section 3.2.2, “VoltDB Stored Procedures and Determinism”.

Code imported using IMPORT CLASS is included in the application catalog and, therefore, can be updated on a running database through the @UpdateApplicationCatalog system procedure. For static libraries that stored procedures use but that do not need to be modified often, the recommended approach is to include the code by placing JAR files in the /lib directory where VoltDB is installed on the database servers.

Example

The following example imports a class containing common financial algorithms so they can be used by any stored procedures in the catalog:

IMPORT CLASS org.mycompany.common.finance;
>