Can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Spring JdbcTemplate Select Query Examples

Spring » On Feb 11, 2012 | { 2 Comments }

Let us see how to use spring JdbcTemplate select query

Files Required

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

Directory Structure

SpringJdbcSelect.java

OurLogic.java

spconfig.xml

Output:

Explanation

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.

 

What you are thinkig....

2 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)
          System.out.println(o.toString());
        }
        }

  2. Java4s says:

    @Raja

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

If you want a pic to show with your comment, go get a gravatar !
Please post your questions on Java4s Answers forum

Name*
Ask a Question ?
or
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links Current & UpComing Tutorials Java4s.com
Tutorials Online :
spring Hibernate struts Json Ajax Log4j Log4j
coreJava Servlets


UpComing :
Jsps,Web Services
Java4s is optimized for learning java technologies, all the examples in this site are constantly reviewed to avoid errors. While using this site you agree to have read and accepted our terms of use and privacy policy
Especially i have prepared this blog by keeping fresher's in mind, however it will be very useful for real time developers too.


© 2014 Java4s All rights reserved. | strPro4Tut v(2.0) Theme designed by Team Java4s.