JBoss.orgCommunity Documentation

Chapter 2. Teiid extensions to the JDBC API

2.1. Statement Extensions
2.2. Execution Properties
2.3. Set Statement
2.4. Partial Results Mode
2.5. XML extensions
2.5.1. Document formatting
2.5.2. Schema validation

The Teiid statement extension interface, org.teiid.jdbc.TeiidStatement, provides functionality beyond the JDBC standard. To use the extension interface, simply cast or unwap the statement returned by the Connection. The following methods are provided on the extension interface:


Execution properties may be set on a per statement basis through the TeiidStatement interface or on the connection via the SET statement. For convenience, the property keys are defined by constants on the org.teiid.jdbc.ExecutionProperties interface.


Execution properties may also be set on the connection by using the SET statement. The SET statement is not yet a language feature of Teiid and is handled only in the JDBC client.

The SET statement is most commonly used to control planning and execution.


The Teiid Server supports a "partial results" query mode. This mode changes the behavior of the query processor so the server returns results even when some data sources are unavailable.

For example, suppose that two data sources exist for different suppliers and your data Designers have created a virtual group that creates a union between the information from the two suppliers. If your application submits a query without using partial results query mode and one of the suppliers’ databases is down, the query against the virtual group returns an exception. However, if your application runs the same query in “partial results” query mode, the server returns data from the running data source and no data from the data source that is down.

When using "partial results" mode, if a source throws an exception during processing it does not cause the user’s query to fail. Rather, that source is treated as returning no more rows after the failure point. Most commonly, that source will return 0 rows.

This behavior is most useful when using UNION or OUTER JOIN queries as these operations handle missing information in a useful way. Most other kinds of queries will simply return 0 rows to the user when used in partial results mode and the source is unavailable.

For each source that is excluded from the query, a warning will be generated describing the source and the failure. These warnings can be obtained from the ResultSet.getWarnings() method. This method returns a SQLWarning object but in the case of "partial results" warnings, this will be an object of type org.teiid.jdbc.PartialResultsWarning class. This class can be used to obtain a list of all the failed sources by name and to obtain the specific exception thrown by each resource adaptor.

Below is an example of printing the list of failed sources:

statement.setExecutionProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, “true”);
ResultSet results = statement.executeQuery(“SELECT Name FROM Accounts”);
SQLWarning warning = results.getWarnings();
if(warning instanceof PartialResultsWarning) {
	PartialResultsWarning partialWarning = (PartialResultsWarning) warning;
 	Collection failedConnectors = partialWarning.getFailedConnectors();
 	Iterator iter = failedConnectors.iterator();
 	while(iter.hasNext()) {
 		String connectorName = (String) iter.next();
 		SQLException connectorException =  partialWarning.getConnectorException(connectorName);
 		System.out.println(connectorName + “: “ +ConnectorException.getMessage();
    }
}

The XML extensions apply on to XML resutls from queries to XML document models, and not to XML produced by SQL/XML or read from some other source.