Spring JdbcTemplate Select Query Examples

Spring » On Feb 11, 2012 By Sivateja

Let us see how to use spring JdbcTemplate select query

Files Required

  • SpringJdbcSelect.java
  • OurLogic.java
  • spconfig.xml

Directory Structure






See the xml file.. actually our beam is id3, which needs JdbcTemplate to use the methods so i have given <ref bean=”id2″/>, and JdbcTemplate(id2) class need DriverManagerDataSource help so i have given <ref bean=”id1“/>, hope you got it.

Java/J2EE Developer & Web Designer, founder of Java4s.com. Sign-up for the email newsletter for your daily dose of Java tutorials.
Email: sivateja@java4s.com


7 Responses to “Spring JdbcTemplate Select Query Examples”
  1. Raja says:

    In SpringJdbcSelect.java instead of iterating the list trough Iterator its better to use for-each loop then code will be like

      public void loadAll()
          List l = jt.queryForList(“select * from countries”);
          for (Object o : l)

  2. Java4s says:


    Yeah we can use either Iterator or Foreach, actually its depends, will not possible in all the cases :-)

  3. 1.How can i connect with sql database please tell me…..
    2.how can i create tabe in mysql with Spring framework…

    Give me one-one example like oracle database

  4. Divya says:

    1.How to get the values from Login form and
    2.How to check that the person is valid user or not by using JdbcTemplate……. plz explain it with a small Login web application

  5. Harshitha says:

    Hi I am getting the foolowing error: Error creating bean with name ‘id3′

  6. Giri says:

    Check configuration file what u given for bean id.

    might be wrong name u given

  7. Sangeetha says:

    Hi, Please make sure your have added respective driver jar. ex : for db2 , we need to add “db2jcc-9.jar”


By posting your answer, you agree to our comments policy.
© 2010 - 2016
Java4s - Get It Yourself.
The content & design is copyrighted to Sivateja Kandula, it may not be reproduced on other websites.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs

Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links
Current & UpComing Tutorials
  Web Services [ SOAP ], JSP
Facebook_Java4s  Twitter_Java4s  GooglePlus_Java4s  Youtube_Java4s 
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.