Using Cloudscape's Java Extensions
Page 3 of 12

Referring to Classes Within SQL-J

The SQL-J language allows you to refer to Java classes as well as instances of those classes. For example, you may need to refer to the class itself when calling static methods, defining a column data type, or instantiating a class. You can do this in one of two ways:

  • You refer to the Java class with its full package and class name (in addition, sometimes you must also use the CLASS keyword). For example:

    VALUES NEW java.lang.String('hello, world!')

    You must use the CLASS keyword when casting and when calling static methods, as in the following example:

    CAST
        (? AS CLASS JBMSTours.serializabletypes.Tour)

  • You create a class alias for the Java class name, and then refer only to the alias (you will not ever need to use the CLASS keyword).

    Cloudscape provides built-in class aliases for Cloudscape classes.

    For example:

    CREATE CLASS ALIAS String FOR java.lang.String

    VALUES NEW String('hello, world!')

For more information about creating class aliases, see CREATE CLASS ALIAS statement in the Cloudscape Reference Manual.