title: Closing resultset and prepared statment connections for Spring datasource object
body: <p>I am very new for spring F/w. I am using spring jdbc and spring ORM  in my application as persistance layer. I have a doubt like, In a method which calls multiple times, do we need to close the result-set object and statement object. 
  Sample code is:</p>
  
  <pre><code>public   void  savedata() throws Throwable
      {
          Connection connection = null;
          try 
              {
              int lastUpdated= jdbcTemplate.queryForInt("select serial_id from serial_details ");
          SerialUpdated=jdbcTemplate.queryForInt("select count(* ) from serial_usg  where serial_bill is null  " +
                      " and SURROGATE_KEY &gt; "+lastUpdated);
  
              connection = dataSource.getConnection();
              String Query = "select * from serial_mst where serial_bill is null  and " +
                      "SURROGATE_KEY  &gt; "+ lastUpdated ;
              PreparedStatement pStatement = connection.prepareStatement(Query);          
              ResultSet rs = pStatement.executeQuery();       
              while(rs.next()){
                  String data     = rs.getString("serial_bill");                          
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }               
              }
  
          } catch (Exception e) {
              e.printStackTrace();
          }finally{
              if(connection != null &amp;&amp; !connection.isClosed()){
                  connection.close();
                  connection = null;
              }           
          } 
  </code></pre>
  
  <p>My Question is, If i call this method multiple times, then do i need to close statement and result-set methods or only connection object is enough to close.</p>