jaguar.sql.JServerResultSet interface

Description

package com.sybase.jaguar.sql;
public interface JServerResultSet extends Object 

Provides methods to send rows to the client. JServerResultSet is similar to the java.sql.ResultSet interface, which is used to retrieve result rows from a server.

Constructors

Call JContext.createServerResultSet(JServerResultSetMetaData).

Methods

Usage

A JServerResultSetMetaData instance is required to construct a JServerResultSet. JServerResultSetMetaData describes the format of rows in the result set. After initializing the JServerResultSetMetaData instance, call JContext.createServerResultSet(JServerResultSetMetaData).

The cursor of a JServerResultSet is initially positioned before the first row. An initial next() call is required to move the cursor to the first row.

Subsequent calls to next() add new rows; each should be preceded by set<Object>(int, <Object>) or setNull(int) calls to set column values for the row.

You can add any number of rows with next(). Once all rows have been added, call the done() method to indicate the end of the result set.

After the done() method finishes, the JServerResultSet is again positioned before the first row. The same JServerResultSet instance can be used to another result set based on the same metadata.

Implementations of the JServerResultSet interface may buffer rows as needed during consecutive next() calls before sending them to the client. The done() method should flush any buffered rows (and flush network buffers as well, if possible—the EAServer done() implementation flushes network buffers).

“Sending result sets with Java” in the EAServer Programmer’s Guide summarizes the call sequences to send result sets and contains examples.

See also

JContext.forwardResultSet(ResultSet)




JServerResultSet.done()

Description

Indicates that all rows in a result set have been sent.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract void done() 
    throws SQLException 

Usage

You must call the done() method to indicate that all rows in a result set have been sent.




JServerResultSet.findColumn(String)

Description

Returns the index for the column that has the specified name.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract int findColumn( String columnName)
    throws SQLException 

Parameters

columnName

The name of the column of interest.

Returns

The index of the column whose name matches the supplied name. Throws a SQLException if no column has a matching name. The index of the first column is 1.

See also

JServerResultSetMetaData.setColumnName(int, String)




JServerResultSet.getMetaData()

Description

Returns a java.sql.ResultSetMetaData object that describes the rows in a result set. The metadata includes the number of columns, the datatype of each column, and other details about each column, such as whether values can be NULL.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract ResultSetMetaData getMetaData()
    throws SQLException 

Returns

A java.sql.ResultSetMetaData object that describes the rows in a result set.

Usage

A JServerResultSet object’s metadata is determined when the object is constructed by calling createServerResultSetMetaData(). The metadata cannot be changed afterwards.

See also

java.sql.ResultSetMetaData, createServerResultSetMetaData(), createServerResultSet(JServerResultSetMetaData), java.sql.ResultSet.getMetaData()




JServerResultSet.next()

Description

Sends a row to the client.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract boolean next() throws SQLException 

Returns

true if the row was successfully created, false otherwise.

Usage

The cursor of a JServerResultSet object is positioned before the first row when the object is constructed. An initial next() call is required to move the cursor to the first row. A done() call repositions the cursor before the first row.

After the first next() call, subsequent calls to next() add new rows; each should be preceded by set<Object>(int, <Object>) or setNull(int) calls to set column values for the row.

Any number of rows can be sent with next(). Once all rows have been sent, the done() method must be called to indicate the end of the result set.

See also

done(), ResultSet.next()




JServerResultSet.setBigDecimal(int, BigDecimal, int)

Description

Specifies a non-NULL value for a java.math.BigDecimal column.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract void setBigDecimal
    (int columnIndex, 
     BigDecimal columnValue, 
    int scale) throws SQLException 

Parameters

columnIndex

The index of the column whose value is being set. The first column is 1.

columnValue

A java.math.BigDecimal value.

scale

The scale of the value. The scale specifies the number of decimal digits to the right of the decimal point.

Usage

Use setBigDecimal methods to specify values for non-NULL java.math.BigDecimal column values. If a column’s value is NULL, call setNull(int).

You can set values for columns within a row in any order.

See also

ResultSet.getBigDecimal(int, int)




JServerResultSet.setCurrency(int, long)

Description

Specifies a non-NULL value for a column that represents a cash value.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract void setCurrency
    (int columnIndex, 
    long columnValue)
    throws SQLException 

Parameters

columnIndex

The index of the column whose value is being set. The first column is 1.

columnValue

The column’s value, expressed as the number of one-ten-thousandths of a cash unit. In other words, columnValue represents the cash value:

columnValue/10000

Usage

You must call setCurrency to specify values for columns that represent a cash value. The result set’s metadata specifies whether a column represents a cash value (ResultSetMetaData.isCurrency(int) returns true for the column).

setCurrency throws a SQLException if the column does not represent a cash value.

See also

ResultSet.getBigDecimal(int, int), ResultSetMetaData.isCurrency(int), JServerResultSetMetaData.setCurrency(int, boolean)




JServerResultSet.setNull(int)

Description

Specifies that a column in the current row has value NULL.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract void setNull(int columnIndex) 
    throws SQLException 

Parameters

columnIndex

The index of the column whose value is being set. The first column is 1.

Usage

An exception is thrown if the ResultSet object’s metadata does not allow NULL values for the column.

See also

JServerResultSetMetaData.setNullable(int, int), JServerResultSet.getMetaData(), ResultSet.wasNull()




JServerResultSet.set<Object>(int, <Object>)

Description

Specifies a non-NULL value for a column in the current row.

Syntax

Package

com.sybase.jaguar.sql

Interface

JServerResultSet

public abstract void setASCIIStream 
    (int columnIndex, java.io.InputStream columnValue) 
    throws SQLException, IOException
public abstract void setBinaryStream 
    (int columnIndex, java.io.InputStream columnValue) 
    throws SQLException, IOException
public abstract void setBoolean 
    (int columnIndex, boolean columnValue) 
    throws SQLException 
public abstract void setByte 
    (int columnIndex, byte columnValue) 
    throws SQLException 
public abstract void setDouble 
    (int columnIndex, double columnValue) 
    throws SQLException
public abstract void setDouble 
    (int columnIndex, double columnValue) 
    throws SQLException
public abstract void setFloat 
    (int columnIndex, float columnValue) 
    throws SQLException
public abstract void setInt 
    (int columnIndex, int columnValue) 
    throws SQLException
public abstract void setShort 
    (int columnIndex, short columnValue) 
    throws SQLException
public abstract void setString 
    (int columnIndex, java.lang.String columnValue) 
    throws SQLException
public abstract void setTimestamp 
    (int columnIndex, java.sql.Timestamp columnValue) 
    throws SQLException

Parameters

columnIndex

The index of the column whose value is being set. The first column is 1.

columnValue

An object of the appropriate type that contains the value for the column. The object type must match the column type that was specified by JServerResultSetMetaData.setColumnType(int, int) for the result set’s metadata. Table 1-1 lists type mappings.

Usage

Use the set<Object> methods to specify values for non-NULL column values. If a column’s value is NULL, call setNull(int).

You can set values for columns within a row in any order.

See also

JServerResultSetMetaData.setColumnType(int, int), setBigDecimal(int, BigDecimal, int), java.sql.ResultSet