title: How to set up different databases per environment in Play 2.0?
body: <p>I'd like my Play app to use different databases for test, local and production (production is Heroku) environments.</p>
  
  <p>In <code>application.conf</code> I have: </p>
  
  <pre><code>db.default.driver=org.postgresql.Driver 
  
  %dev.db.default.url="jdbc:postgresql://localhost/foobar" 
  %test.db.default.url="jdbc:postgresql://localhost/foobar-test" 
  %prod.db.default.url=${DATABASE_URL} 
  </code></pre>
  
  <p>This doesn't seem to work. When I run <code>play test</code> or <code>play run</code>, 
  all DB access fails with: </p>
  
  <pre><code> Configuration error [Missing configuration [db.default.url]] (Configuration.scala:258) 
  </code></pre>
  
  <p>I have a few questions about this:</p>
  
  <ul>
  <li><p>In general, I'm a little confused about how databases are configured 
  in Play: it looks like there's plain <code>db</code>, <code>db.[DBNAME]</code> and <code>db. 
  [DBNAME].url</code> and different tutorials make different choices among 
  those. Certain expressions that seem like they should work (e.g. <code>db.default.url  = "jdbc:..."</code> fail with an error that a string was provided where an object was expected).</p></li>
  <li><p>I've seen other people suggest that I create separate <code>prod.conf</code>, <code>dev.conf</code> and <code>test.conf</code> files that each include <code>application.conf</code> and then contain DB-specific configuration. But in that case, how do I specify what database to use when I run <code>test</code> from the Play console? </p></li>
  <li><p>Is the <code>%env</code> syntax supposed to work in Play 2?</p></li>
  <li><p>What's the correct way to specify an environment for <code>play test</code> to use?</p></li>
  </ul>