Example usage for org.springframework.jdbc.support.rowset SqlRowSet getRow

List of usage examples for org.springframework.jdbc.support.rowset SqlRowSet getRow

Introduction

In this page you can find the example usage for org.springframework.jdbc.support.rowset SqlRowSet getRow.

Prototype

int getRow() throws InvalidResultSetAccessException;

Source Link

Document

Retrieve the current row number.

Usage

From source file:transaction.script.ProjectTrScript.java

/**
 * @param template//from  w ww .j  a  v a 2  s  .co  m
 * @param query
 * @param conditionsMapList
 * @return
 * @throws SQLException
 */
public static boolean query(JdbcTemplate template, String query, List<Map<String, Object>> conditionsMapList)
        throws SQLException {
    logger.info("Query to execute is: " + query);

    SqlRowSet set = template.queryForRowSet(query);
    boolean result = true;

    SqlRowSetMetaData mdata = set.getMetaData();
    int columnAmount = mdata.getColumnCount();
    logger.info("Columns: " + columnAmount);
    logger.info("Map size: " + conditionsMapList.size());

    //TODO
    if (set.first()) {
        set.last();
        int rowNum = set.getRow();
        result = (rowNum == conditionsMapList.size());
        set.beforeFirst();
    } else {
        if (!conditionsMapList.get(0).isEmpty()) {
            result = false;
        }
    }

    logger.info("Two maps comparison result is " + result);

    if (result) {
        while (set.next()) {
            int rowNum = set.getRow();

            Map<String, Object> map = conditionsMapList.get(rowNum - 1);

            for (int i = 1; i <= columnAmount; i++) {
                result &= map.containsKey(mdata.getColumnName(i))
                        && map.get(mdata.getColumnName(i)).toString().equals(set.getObject(i).toString());
            }
        }
    }
    return result;
}

From source file:transaction.script.ClearQuestTrScript.java

/**
 * TODO: ?   DC//from  w  ww.ja v  a2s.c o  m
 * @param projectName
 * @return
 * @throws SQLException
 */
public HashMap<String, String> getAllBuildDefChanges(String projectName) throws SQLException {
    Checker.checkStringForEmpty("project name", projectName, false);

    String query = dcQueryTemplate.substitute("project", projectName);

    JdbcTemplate template = JdbcTemplateFactory.getClearQuestDBTemplate();

    HashMap<String, String> dcMap = new HashMap<String, String>();

    logger.info("query \n" + query);

    SqlRowSet set = template.queryForRowSet(query);
    logger.info("resultset rows count " + set.getRow());

    while (set.next()) {
        logger.info("resultset rows count " + set.getRow());

        dcMap.put(set.getString(DCNUMBER), set.getString(HEADLINE));
    }

    return dcMap;
}