Java 类org.springframework.jdbc.core.RowCountCallbackHandler 实例源码

项目:jql    文件:StringResultSetExtractor.java   
@Override
public String extractData(ResultSet resultSet) throws SQLException, DataAccessException {
    RowCountCallbackHandler rowCountCallbackHandler = new RowCountCallbackHandler();
    rowCountCallbackHandler.processRow(resultSet);
    int columnCount = resultSet.getMetaData().getColumnCount();
    List<String> columnNames = asList(rowCountCallbackHandler.getColumnNames());
    String header = getHeader(columnNames);

    StringBuilder result = new StringBuilder(header);
    result.append("\n");

    while (resultSet.next()) {
        StringBuilder stringBuilder = new StringBuilder();
        int i = 1;
        while (i <= columnCount) {
            stringBuilder.append(resultSet.getObject(i));
            if (i < columnCount) {
                stringBuilder.append(" | ");
            }
            i++;
        }
        result.append(stringBuilder.toString()).append("\n");
    }

    return result.toString();
}
项目:jql    文件:QueryExecutor.java   
public int count(String countQuery) {
    RowCountCallbackHandler rowCountCallbackHandler = new RowCountCallbackHandler();
    jdbcTemplate.query(countQuery, rowCountCallbackHandler);
    return rowCountCallbackHandler.getRowCount();
}
项目:opennmszh    文件:TemporaryDatabase.java   
public int countRows(String sql, Object... values) {
    RowCountCallbackHandler counter = new RowCountCallbackHandler();
    getJdbcTemplate().getJdbcOperations().query(sql, values, counter);
    return counter.getRowCount();
}
项目:OpenNMS    文件:TemporaryDatabase.java   
public int countRows(String sql, Object... values) {
    RowCountCallbackHandler counter = new RowCountCallbackHandler();
    getJdbcTemplate().getJdbcOperations().query(sql, values, counter);
    return counter.getRowCount();
}