Results 1 to 3 of 3

Thread: Resultset Metadata from JDBCTemplate Query methods

  1. #1
    Join Date
    May 2010
    Posts
    13

    Default Resultset Metadata from JDBCTemplate Query methods

    Is there any way I can get resultset object from one of jdbctemplate query methods?

    I have a code like

    Code:
    List<ResultSet> rsList = template.query(finalQuery, new RowMapper<ResultSet>() {
                public ResultSet mapRow(ResultSet rs, int rowNum) throws SQLException {
                    return rs;
                }
                }
                );
    I wanted to execute my sql statement stored in finalQuery String and get the resultset. The query is a complex join on 6 to 7 tables and I am select 4-5 columns from each table and wanted to get the metadata of those columns to transform data types and data to downstream systems.

    If it is a simple query and I am fetching form only one table I can use RowMapper#mapRow and inside that maprow method i can call ResultsetExtractor.extractData to get list of results; but in this case I have complex joins in my query and I am trying to get resultset Object and from that resultset metadata...

    The above code is not good because for each result it will return same resultset object and I dont want to store them in list ...

    Once more thing is if maprow is called for each result from my query will JDBCTemplate close the rs and connection even though my list has reference to RS object?

    Is there any simple method like jdbcTemplate.queryForResultSet(sql) ?

  2. #2

    Default

    even I want to know this...plz someone help us out

  3. #3
    Join Date
    May 2010
    Posts
    13

    Default

    See this.. http://stackoverflow.com/questions/5...-query-methods.

    This is a custom soltuion for my problem but you can write your Own Resultset extractor by implementing ResultSetExtractor and form there you can play with your resultset Object...

    something like

    Code:
    public class CustomResultSetProcessor implements ResultSetExtractor<Object>
    {
        @Override
        public Object extractData(ResultSet rs)
        {
          // Here play with your Rs or simply return RS
        }
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •