title: How to specify character encoding for h2 in memory database scripts?
body: <p>I have troubles with character encoding in my <strong>JPA</strong> test class.</p>
  
  <p>In my <strong>h2 in memory database</strong> I have this <strong>insert query</strong> :</p>
  
  <pre><code>INSERT INTO MYTABLE (ID,FIELD1,FIELD2) VALUES (100,'ABC','Réclamation');
  </code></pre>
  
  <p>(please notice the "é" character in "Réclamation")</p>
  
  <p>In my JUnit Test, I try to assert that the value of FIELD2 column is equal to "Réclamation" (which is the case as you can see)</p>
  
  <p>But it fails with the following error :</p>
  
  <blockquote>
    <p>org.junit.ComparisonFailure: expected:R[é]clamation but
    was: R[�]clamation</p>
  </blockquote>
  
  <p><strong>I wonder if there is a way to specify character encoding in persistence.xml file</strong> (maybe ? or somewhere else)</p>
  
  <p>Here is my persistence.xml test file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence
      version="2.1"
      xmlns="http://xmlns.jcp.org/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
               http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"&gt;
  
      &lt;persistence-unit name="myTestPU"&gt;
          &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
          &lt;class&gt;com.myproject.myclass1&lt;/class&gt;
          &lt;class&gt;com.myproject.myclass2&lt;/class&gt;
          &lt;properties&gt;
              &lt;property
                  name="javax.persistence.schema-generation.database.action"
                  value="none" /&gt;
              &lt;property
                  name="javax.persistence.sharedCache.mode"
                  value="ENABLE_SELECTIVE" /&gt;
              &lt;property
                  name="javax.persistence.jdbc.url"
                  value="jdbc:h2:mem:test;INIT=RUNSCRIPT FROM 'classpath:ddl/schema.sql'\;RUNSCRIPT FROM 'classpath:ddl/data.sql'" /&gt;
              &lt;property
                  name="javax.persistence.jdbc.driver"
                  value="org.h2.Driver" /&gt;
              &lt;property
                  name="hibernate.dialect"
                  value="org.hibernate.dialect.H2Dialect" /&gt;
              &lt;property
                  name="hibernate.show_sql"
                  value="true" /&gt;
              &lt;property
                  name="hibernate.format_sql"
                  value="true" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>I've already tried these solutions :</p>
  
  <ul>
  <li><p>adding the following properties in persistence.xml test file : </p>
  
  <pre><code>&lt;property
      name="hibernate.connection.characterEncoding"
      value="utf8" /&gt;
  &lt;property
      name="hibernate.connection.useUnicode"
      value="true" /&gt;
  &lt;property
      name="hibernate.connection.charSet"
      value="UTF-8" /&gt;
  </code></pre></li>
  <li><p>adding <code>?useUnicode=yes&amp;amp;characterEncoding=UTF-8</code> in my URL property</p></li>
  </ul>
  
  <p>None of them worked for me...</p>
  
  <p>NB : I don't use spring framework in my application</p>