Example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcOperations queryForRowSet

List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcOperations queryForRowSet

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcOperations queryForRowSet.

Prototype

SqlRowSet queryForRowSet(String sql, Map<String, ?> paramMap) throws DataAccessException;

Source Link

Document

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a SqlRowSet.

Usage

From source file:org.geoserver.jdbcconfig.internal.DbMappings.java

private BiMap<Integer, Class<?>> loadTypes(NamedParameterJdbcOperations template) {
    String sql = "select oid, typename from type";
    SqlRowSet rowSet = template.queryForRowSet(sql, params("", ""));
    BiMap<Integer, Class<?>> types = HashBiMap.create();
    if (rowSet.first()) {
        do {//from   w  ww . ja  va  2  s  . c o m
            Number oid = (Number) rowSet.getObject(1);
            String typeName = rowSet.getString(2);
            Class<?> clazz;
            try {
                clazz = Class.forName(typeName);
            } catch (ClassNotFoundException e) {
                throw Throwables.propagate(e);
            }
            types.put(oid.intValue(), clazz);
        } while (rowSet.next());
    }
    return types;
}