use of org.teiid.odata.api.SQLParameter in project teiid by teiid.
the class TestODataSQLBuilder method helpTest.
public QueryState helpTest(String url, String sqlExpected, Integer skip, Integer top, Boolean count) throws Exception {
QueryState state = setup(url);
Client client = state.client;
ArgumentCaptor<Query> arg1 = ArgumentCaptor.forClass(Query.class);
ArgumentCaptor<EntityCollectionResponse> arg6 = ArgumentCaptor.forClass(EntityCollectionResponse.class);
List<SQLParameter> parameters = new ArrayList<SQLParameter>();
if (sqlExpected != null) {
Query actualCommand = (Query) QueryParser.getQueryParser().parseCommand(sqlExpected, new ParseInfo());
Mockito.verify(client).executeSQL(arg1.capture(), Mockito.eq(parameters), Mockito.eq(count), (Integer) Mockito.eq(skip), (Integer) Mockito.eq(top), (String) Mockito.eq(null), Mockito.anyInt(), arg6.capture());
Assert.assertEquals(actualCommand.toString(), arg1.getValue().toString());
}
state.parameters = parameters;
state.arg1 = arg1;
state.arg6 = arg6;
return state;
}
use of org.teiid.odata.api.SQLParameter in project teiid by teiid.
the class LocalClient method executeCall.
@Override
public void executeCall(String sql, List<SQLParameter> parameters, ProcedureReturnType returnType, OperationResponse response) throws SQLException {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_ODATA, "Teiid-Query:", sql);
final CallableStatement stmt = getConnection().prepareCall(sql);
int i = 1;
if (!returnType.hasResultSet()) {
stmt.registerOutParameter(i++, returnType.getSqlType());
}
if (!parameters.isEmpty()) {
for (SQLParameter param : parameters) {
stmt.setObject(i++, param.getValue(), param.getSqlType());
}
}
boolean results = stmt.execute();
if (results) {
final ResultSet rs = stmt.getResultSet();
while (rs.next()) {
response.addRow(rs);
}
}
if (!returnType.hasResultSet()) {
Object result = stmt.getObject(1);
response.setReturnValue(result);
}
}
Aggregations