title: Why creating datasource in standalone.xml in Jboss EAP 6.4 is giving longer response time as compared to when datasource is created in code manually
body: <p>I have a web application where i am using jboss EAP 6.4. There i am using two configurations for creating datasource. Datasource is defined in standalone file also and if while creating datasource object any exception is thrown then data source is created manually in code. Code for the same is given below:</p>
  
  <pre><code>@Bean
      public DataSource getDataSource() {
          try {
              Object object = new JndiTemplate().lookup(JNDI);
              return DataSource) object;
          } catch (NamingException e) {
              DriverManagerDataSource dataSource = new DriverManagerDataSource();
              dataSource.setDriverClassName(---);
              dataSource.setUrl(---);
              dataSource.setUsername(---);
              dataSource.setPassword(---);
  
              return dataSource;
          }
      }
  </code></pre>
  
  <p>Here is my standalone.xml snippet</p>
  
  <pre><code>&lt;datasource jta="false" jndi-name="xyz" pool-name="xyDatasource" enabled="true" use-ccm="false"&gt;
                      &lt;connection-url&gt;jdbc:oracle:thin:@localhost:1521:xe&lt;/connection-url&gt;
                      &lt;driver&gt;OracleJDBCDriver&lt;/driver&gt;
                      &lt;pool&gt;
                          &lt;min-pool-size&gt;20&lt;/min-pool-size&gt;
                          &lt;max-pool-size&gt;30&lt;/max-pool-size&gt;
                          &lt;use-strict-min&gt;true&lt;/use-strict-min&gt;
                          &lt;flush-strategy&gt;FailingConnectionOnly&lt;/flush-strategy&gt;
                      &lt;/pool&gt;
                      &lt;security&gt;
                          &lt;user-name&gt;abc&lt;/user-name&gt;
                          &lt;password&gt;xyz&lt;/password&gt;
                      &lt;/security&gt;
                      &lt;validation&gt;
                          &lt;validate-on-match&gt;false&lt;/validate-on-match&gt;
                          &lt;background-validation&gt;false&lt;/background-validation&gt;
                      &lt;/validation&gt;
                      &lt;statement&gt;
                          &lt;share-prepared-statements&gt;false&lt;/share-prepared-statements&gt;
                      &lt;/statement&gt;
         &lt;/datasource&gt;
  </code></pre>
  
  <p>The problem here is when connection is created successfully using standalone version datasource at that time the response time for all the requests are pretty high as compared to when its is created in code in catch condition.</p>
  
  <p>I  searched a lot but didn't find any reason for it.</p>