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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:33:38+00:00 2026-05-26T09:33:38+00:00

I am using the spring mvc3 in my applicatio,and in the dao layer I

  • 0

I am using the spring mvc3 in my applicatio,and in the dao layer I want to use jdbctemplate,however I do not know where to add the dao,in the controller?

For example:

@Controller
public class UserController{
  private UserDao udao;
  public String list(Model model){
    udao=new UserDaoImple();
    List<User> users=udao.list();
    model.addAttrubut('users',users);
    return "list";
  }
}

The above code is just an example,I want to know where to create the userdao?

Also,since I want to use the jdbctemplate,and it is recommended that the jdbctemplate is created only once for one datasourece,so how to make all the daos use the same jdbctemplate?

  • 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-05-26T09:33:39+00:00Added an answer on May 26, 2026 at 9:33 am

    You could use Spring IOC (dependency injection) to inject the DAO like this

    @Autowired
    UserDao userdao;
    

    or you could use the repository pattern, and create a central point for all the DAOs so you just go to the repository and ask for the DAO you need.

    for that you would have to create singleton class that has all instances of all DAOs and when asked give give an instance to your class, so you don’t need to instantiate the Dao just do a

    Repo.getUserDaoInstance();
    

    In my opinion, go for the Spring approach you will learn a very useful skill and it’s a lot easier to maintain when you know what you are doing.

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

Sidebar

Related Questions

I am developing project using Spring , Struts2 & Hibernate . Now I want
I'm using Spring, Spring Security, BlazeDS, Flex and spring-flex. I know that I can
I have a webapp which is built using spring 3 and tiles 2 (not
Im want to create a data structure for using within my MVC3 application. The
I'm currently developing a multi-tiered application, using MVC3 and Spring.NET all of which is
I'm using Spring MVC 3.0 with sitemesh and spring message bundles. For example, I
i am using telerik grid in my Asp.Net MVC3 application and i want to
Using Spring 2.5 tag library, I have an Integer value in a command form
When using spring security, specifically with @notation; what is the proper way to access
I'm using Spring with Hibernate as a JPA provider and are trying to get

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.