use of org.teiid.jdbc.TeiidStatement in project teiid by teiid.
the class TestAsynch method testAsynchContinuousWithAlter.
@Test
public void testAsynchContinuousWithAlter() throws Exception {
Statement stmt = this.internalConnection.createStatement();
TeiidStatement ts = stmt.unwrap(TeiidStatement.class);
final ResultsFuture<Integer> result = new ResultsFuture<Integer>();
ts.submitExecute("select * from test", new StatementCallback() {
int rowCount;
@Override
public void onRow(Statement s, ResultSet rs) {
try {
rowCount++;
if (rowCount < 3) {
assertEquals(1, rs.getInt(1));
if (rowCount == 2) {
Statement st = internalConnection.createStatement();
st.execute("alter view v.test as select 2");
st.close();
try {
// we only track down to millisecond resolution
Thread.sleep(100);
} catch (InterruptedException e) {
result.getResultsReceiver().exceptionOccurred(e);
}
}
} else {
// new value
assertEquals(2, rs.getInt(1));
s.close();
}
} catch (SQLException e) {
result.getResultsReceiver().exceptionOccurred(e);
throw new RuntimeException(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().continuous(true));
assertEquals(3, result.get().intValue());
}
Aggregations