title: Should I define datasources in application or in app server?
body: <p>I've developed applications (running on Jboss server) with two different teams. One team had datasource configuration inside of the application WAR file and another one had it inside of the application server's standalone.xml. And I'm not sure which approach is better.</p>
  
  <p>So, here are some advantages that I've found in defining datasource inside of the server's standalone.xml. </p>
  
  <ul>
  <li>Defining datasource in server's standalone.xml is more secure than in war file. If the database connection credentials stored in the server's standalone.xml, which is almost never modified, it is safer than having the password inside of the war file, which is often transferred from developer's machines to the server and database configuration is spread by all developers computers.</li>
  <li>By having datasource in standalone.xml, we can make war file smaller, as JDBC driver could be installed as a module and can be removed from war file. In addition, loading JDBC as module is more efficient as from classpath.</li>
  <li>We can put datasource inside of the standalone.xml if we don't want the application development team be aware of database connection settings.</li>
  </ul>
  
  <p>By having datasource configurations in application WAR file, I see the following advantages, which are:</p>
  
  <ul>
  <li>Development team doesn't have permission to change Jboss configuration files in environment where Jboss is running. So DB connection only can be defined in application.</li>
  <li>It is useful in development state, when developers often need to switch between different database connections. For example, the developer can specify connection when building a WAR file.</li>
  </ul>
  
  <p>So I'd like to know if there are another advantages in both approaches. And on your opinion which approach is better?</p>