Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8525009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:51:03+00:00 2026-06-11T07:51:03+00:00

How do I use the JdbcTemplate.query()/queryForList() to run a query using namedParameter and store

  • 0

How do I use the JdbcTemplate.query()/queryForList() to run a query using namedParameter and store the result set into a List of ‘User’s?

User Class:

public class User {

    String name = null;
    String id = null;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return name;
    }
    public void setId(String id) {
        this.id = id;
    }
}

Query:

SELECT name, id FROM USERS where email=:email

I’m looking for something like:

ArrayList<User> userList = jdbcTemplate.query(sql_query, 
                                              ...some_mapper..., etc);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:51:04+00:00Added an answer on June 11, 2026 at 7:51 am

    Seems like the answer to the question is not available at one place, on the Internet. Here’s what I found out:

    For adding the resultset into a List<>, we can use the NamedParameterJdbcTemplate.query() function:

    NamedParameterJdbcTemplate jdbcTemplate;
    
    ArrayList<User> usersSearchResult = (ArrayList<User>) jdbcTemplate.query(
      USER_LIST_TP_query,
      namedParameters,
      new RowMapperResultSetExtractor<User>(new UserRowMapper(), 20));
    

    We also have to define a custom RowMapperResultSetExtractor so that JDBC can understand how to convert each row in the result set to the type User.

    private class UserRowMapper implements RowMapper<User> {
    
      public User mapRow(ResultSet rs, int rowNum) throws SQLException {
        User user = new User();
    
        user.setId(rs.getString("ID"));
        user.setName(rs.getString("NAME"));
    
        return user;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Will the Hibernate caching(1st, 2nd, or Query) work when I use JdbcTemplate? I got
We are looking into using the JdbcTemplate for accessing the DB - but we
Use Case: End-User searches for something and an ArrayCollection is returned with Result objects.
I use Spring's JdbcTemplate to run an insert SQL statement. The field I want
I'm using Spring's support for JDBC. I'd like to use JdbcTemplate (or SimpleJdbcTemplate) to
Use Case Show a photo uploaded by the user in a square box with
use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =
use Control::CLI; $cli = new Control::CLI('SSH'); $cli->connect(Host=>'10.10.10.10',Username=>'user',Password=>'pwd'); $cli->waitfor('>'); $cli->print('Show XXXXXXXXXXXXXXXXXXXX| grep Active'); @f=$cli->waitfor('>'); print
USE master GO DECLARE @DbName nvarchar(MAX) SET @DbName = N'DataBase' ALTER DATABASE @DbName SET
In my project I use Spring 3.0 JdbcTemplate to implement DAO classes. It provides

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.