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 8515017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:01:31+00:00 2026-06-11T05:01:31+00:00

I am using Spring NamedParameterJdbcTemplate in my search process, but when I get many

  • 0

I am using Spring NamedParameterJdbcTemplate in my search process, but when I get many results, its execution take several time and I don’t know if there are a way to optimize it.
Here my code:

 NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(dataSource);
 StringBuilder sb = new StringBuilder(query);
 query = sb.toString();
 return jt.query(query, map, new MyRowMapper());

Have you any idea please?

Thanks all!

  • 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-11T05:01:32+00:00Added an answer on June 11, 2026 at 5:01 am

    Few things you can do
    1. Why to create instance NamedParameterJdbcTemplate every time when method is invoked? Create it once and pass previously created instance to the method.

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(dataSource);  
    

    keep NamedParameterJdbcTemplate as class attribute and initialize it once.
    2. What you are trying here?

     StringBuilder sb = new StringBuilder(query);
     query = sb.toString();  
    

    Pass query directly to .query() method if its of type String.
    3. Inside MyRowMapper, make sure you are fetching and assigning only required fields in mapRow method. This might be affecting the execution time as mapRow is called once for every record in resultset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using NamedParameterJdbcTemplate for run pl/sql script. But I don't know how can
Using Spring and Struts together gives no error message in the console, but only
Using Spring, I can get all beans of a certain type that are currently
currently using spring 'exposedContextBeanNames' to allow me to display properties in my view but
Using Spring 1.2.1 and oracle.jdbc.pool.OracleDataSource 10.2.0.3.0 I sometimes get a stack trace like below.
I am using the Spring NamedParameterJdbcTemplate to fetch some values from a table. For
Long story below short question: How can I get Spring's NamedParameterJDBCTemplate join Hibernate's session?
When using Spring and Spring's MVC, where should the dependency injection (DI) take place?
When using spring's JdbcTemplate , I am using the row mapper to map results
I am trying to extract ROWID or the primary key using Spring's NamedParameterJdbcTemplate and

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.