@jws:sql Tag

Specifies the SQL statement and associated attributes that correspond to a method in a Database control.

# Syntax

    @jws:sql
        statement="sqlStatement"

        [iterator-element-type="javaType"]

        [array-max-length=integer OR "all"]

# Attributes

statement

Required. The SQL (Structured Query Language) statement that will be executed when the associated Database control method is invoked. The statement may contain substitutions of the form {varName}, where paramName is a parameter of the Database control method (or a member accessible from the parameter).

If the statement is a single line, it may be formatted with and equals sign and quotes, as follows:

    /**
     * @jws:sql statement="SELECT * FROM sometable"
     */
    public HashMap getEverything();

If the statement spans multiple lines, it is delimited with :: (two colons), as follows:

    /**
     * @jws:sql statement::
     *     SELECT name
     *     FROM employees
     *     WHERE name LIKE {partialName}
     * ::
     */
    public String[] partialNameSearch(String partialName);

For a discussion of parameter substitution in the statement attribute, see Parameter Substitution in @jws:sql Statements.

iterator-element-type

Required if Database control method return type is java.util.Iterator. Specifies the underlying class of the Iterator that will be returned by the Database control method. The class must meet specific criteria that are described in the Returning an Object section of Returning a Single Row from a Database Control Method.

array-max-length

Optional. If the return type of the associated Database control method is an array, specifies the maximum size of the array that will be returned. This attribute can be used to set an upper limit on memory usage by a Database control method.

Default value: 1024

Note that if the associated query returns more rows than specified by array-max-length, there is no way to access the excess rows.

The special value "all" will cause all rows that satisfy the query to be returned. Note that this can possibly exhaust all available memory if not used carefully.

If you wish to limit memory usage, you should return an Iterator or a ResultSet. To learn about returning Iterators and ResultSets from a Database control method, see Returning Multiple Rows from a Database Control Method.

# Remarks

The following rules apply to this tag's use:

- The @jws:sql tag may only occur on a method declaration in an interface that extends weblogic.jws.control.DatabaseControl.

- The @jws:sql tag may only occur in a CTRL file.

- The @jws:sql tag may only appear once per method.

Related Topics

Database Control: Using a Database from Your Web Service

Parameter Substitution in @jws:sql Statements

Returning Multiple Rows from a Database Control Method