Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I assume you only have one database active at a time. If this is a valid assumption, you don't really need a loop, instead you need to be able to switch between databases.</p> <p>You can achieve this by declaring the DB-specific properties in profiles, then activate the relevant profile.</p> <p>The configuration below shows how to set profiles for the 3 databases you mention, and use a default in case none is specified. You can omit the default and the build will then fail unless a profile is declared. </p> <p>You'd activate each profile from the command line as follows:</p> <pre><code>mvn test -P h2 mvn test -P mysql mvn test -P postgresql &lt;profiles&gt; &lt;profile&gt; &lt;id&gt;h2&lt;/id&gt; &lt;properties&gt; &lt;db.groupId&gt;com.h2database&lt;/db.groupId&gt; &lt;db.artifactId&gt;h2&lt;/db.artifactId&gt; &lt;db.version&gt;1.1.117&lt;/db.version&gt; &lt;/properties&gt; &lt;/profile&gt; &lt;profile&gt; &lt;id&gt;mysql&lt;/id&gt; &lt;properties&gt; &lt;db.groupId&gt;mysql&lt;/db.groupId&gt; &lt;db.artifactId&gt;mysql-connector-java&lt;/db.artifactId&gt; &lt;db.version&gt;5.1.6&lt;/db.version&gt; &lt;/properties&gt; &lt;/profile&gt; &lt;profile&gt; &lt;id&gt;postgresql&lt;/id&gt; &lt;properties&gt; &lt;db.groupId&gt;postgresql&lt;/db.groupId&gt; &lt;db.artifactId&gt;postgresql&lt;/db.artifactId&gt; &lt;db.version&gt;8.3-603.jdbc4&lt;/db.version&gt; &lt;/properties&gt; &lt;/profile&gt; &lt;/profiles&gt; ... &lt;!--default database, say mysql--&gt; &lt;properties&gt; &lt;db.groupId&gt;mysql&lt;/db.groupId&gt; &lt;db.artifactId&gt;mysql-connector-java&lt;/db.artifactId&gt; &lt;db.version&gt;5.1.6&lt;/db.version&gt; &lt;/properties&gt; </code></pre> <p>You can activate a profile based on the value of an environment variable, for example the configuration below activates the h2 profile if the ACTIVE_DB environment variable is set to "h2".</p> <pre><code> &lt;profile&gt; &lt;id&gt;h2&lt;/id&gt; &lt;activation&gt; &lt;property&gt; &lt;name&gt;ACTIVE_DB&lt;/name&gt; &lt;value&gt;h2&lt;/value&gt; &lt;/property&gt; &lt;/activation&gt; &lt;properties&gt; &lt;db.groupId&gt;com.h2database&lt;/db.groupId&gt; &lt;db.artifactId&gt;h2&lt;/db.artifactId&gt; &lt;db.version&gt;1.1.117&lt;/db.version&gt; &lt;/properties&gt; &lt;/profile&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload