use of org.teiid.jdbc.AsynchPositioningException in project teiid by teiid.
the class TestAsynch method testAsynch.
@Test
public void testAsynch() throws Exception {
Statement stmt = this.internalConnection.createStatement();
TeiidStatement ts = stmt.unwrap(TeiidStatement.class);
final ResultsFuture<Integer> result = new ResultsFuture<Integer>();
ts.submitExecute("select * from sys.tables a, sys.tables b, sys.tables c", new StatementCallback() {
int rowCount;
@Override
public void onRow(Statement s, ResultSet rs) {
rowCount++;
try {
if (!rs.isLast()) {
assertTrue(rs.unwrap(TeiidResultSet.class).available() > 0);
}
if (rowCount == 10000) {
s.close();
}
} catch (AsynchPositioningException e) {
try {
assertEquals(0, rs.unwrap(TeiidResultSet.class).available());
} catch (SQLException e1) {
result.getResultsReceiver().exceptionOccurred(e1);
}
} catch (SQLException e) {
result.getResultsReceiver().exceptionOccurred(e);
}
}
@Override
public void onException(Statement s, Exception e) {
result.getResultsReceiver().exceptionOccurred(e);
}
@Override
public void onComplete(Statement s) {
result.getResultsReceiver().receiveResults(rowCount);
}
}, new RequestOptions());
assertEquals(10000, result.get().intValue());
}
Aggregations