title: Spring JdbcTemplate resultset empty first time
body: <p>Put simply, the problem is that the result set is empty the first time around I call the JdbcTemplate and query the database. </p>
  
  <p>When I access the DAO methods for the second time, I get the expected results. Here is more information about how the classes are setup:</p>
  
  <p>I have a data access object that extends a parent data access object. Parent dao class simply injects the data-sources into the constructors of JdbcTemplate:</p>
  
  <pre><code>public class BaseDao
  {
      private JdbcTemplate usrJdbcTemplate;
  
      public void setUsrDataSource(DataSource usrDataSource)
      {
          this.usrJdbcTemplate = new JdbcTemplate(usrDataSource);
      }
  
      public JdbcTemplate getUsrJdbcTemplate()
      {
          return this.usrJdbcTemplate;
      }
  
  }
  </code></pre>
  
  <p>The class that extends this, makes use of this JdbcTemplate to query a table:</p>
  
  <pre><code>public class OimUserDao extends BaseDao
  {
      public Date getPasswordExpiryDate(String userName)
      {
  
      String sql = "select USR_PWD_EXPIRE_DATE from USR where UPPER (USR_LOGIN) = ?";
  
      List&lt;java.sql.Date&gt; dtLst  = getUsrJdbcTemplate().query(sql, new Object[] {userName.toUpperCase()}, new RowMapper&lt;java.sql.Date&gt;() 
        {
        @Override
        public java.sql.Date mapRow(final ResultSet rs, int rowNum) throws SQLException
        {
        return rs.getDate(1);
        }
        });
  
      if (dtLst.size()&gt;0)
      {
      return dtLst.get(0);
      }
      else
      {
      return null;
      }
      }
  }
  </code></pre>
  
  <p>The DAO is autowired in a service using the @Autowired annotation. DAO declarations in the xml:
      
      
      </p>
  
  <pre><code>&lt;bean id="baseDao" class="us.worldpay.portalgateway.dao.BaseDao"&gt;
      &lt;property name="usrDataSource" ref="usrDataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="oimUserDao" class="us.worldpay.portalgateway.dao.OimUserDao" parent="baseDao" /&gt;
  </code></pre>
  
  <p>Web.xml has the declaration for the xml containing the bean definitions for these DAO (pg-data is the one we are concerned with):</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/pg-servlet.xml,
          /WEB-INF/pg-data.xml
  &lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>To make things worse, this NEVER happens on my local box (Weblogic) that points to the same database (Oracle) as our QA env does. The result set the first time around is populated and has data when I run this on my local box. When I run this on the QA env (Weblogic), the result set is empty the first time. I have spent hours and hours on this, and have gotten no where. </p>
  
  <p>I appreaciate your time reading this post. I am grateful for all help I can get. </p>