use of io.mycat.beans.mycat.JdbcRowBaseIterator in project Mycat2 by MyCATApache.
the class DefaultConnection method executeQuery.
public RowBaseIterator executeQuery(String sql) {
try {
Statement statement = connection.createStatement();
statement.setFetchSize(1);
ResultSet resultSet = statement.executeQuery(sql);
return new JdbcRowBaseIterator(null, this, statement, resultSet, new RowIteratorCloseCallback() {
@Override
public void onClose(long rowCount) {
}
}, sql);
} catch (Exception e) {
throw new MycatException(e);
}
}
use of io.mycat.beans.mycat.JdbcRowBaseIterator in project Mycat2 by MyCATApache.
the class MycatPreparedStatementUtil method executeQuery.
@SneakyThrows
public static RowBaseIterator executeQuery(Connection mycatConnection, MycatConnection connection, MycatRowMetaData calciteRowMetaData, SqlString value, List<Object> params, RowIteratorCloseCallback closeCallback) {
String sql = value.getSql();
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("sql:{} {}", sql, (params).toString());
}
PreparedStatement preparedStatement = mycatConnection.prepareStatement(sql);
ImmutableList<Integer> dynamicParameters = value.getDynamicParameters();
List<Object> outoutParams = extractParams(params, dynamicParameters);
MycatPreparedStatementUtil.setParams(preparedStatement, outoutParams);
ResultSet resultSet = preparedStatement.executeQuery();
return new JdbcRowBaseIterator(calciteRowMetaData, connection, preparedStatement, resultSet, closeCallback, sql);
} catch (Throwable throwable) {
LOGGER.error("sql:{} {}", sql, (params).toString(), throwable);
throw throwable;
}
}
Aggregations