title: How to set useUnicode=true and characterEncoding=utf8 properties on Spring-managed MySQL JDBC connection
body: <p>I'm currently building a Spring MVC webapp and the database is the vital backend part. For whatever reason, however, Spring is refusing to process the data as UTF-8. Since the views, resources and browsers are set to Unicode, and so are the tables in the database (and also reading quite a few similar questions asked), I have established that the problem lies in the database connection.</p>
  
  <p>The JDBC Driver should be provided two items in connectionProperties: useUnicode (set to <em>yes</em> and characterEncoding (set to <em>utf8</em>). It turns out, however, it's <strong>impossible</strong>.</p>
  
  <p>JDBC is a bean, and as such is configured via an XML file, like so:</p>
  
  <pre><code>&lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
  &lt;property name="url" value="jdbc:mysql://localhost:3306/&lt;database&gt;" /&gt;
  &lt;property name="username" value="&lt;not telling&gt;" /&gt;
  &lt;property name="password" value="&lt;not telling&gt;" /&gt;
  </code></pre>
  
  <p>This setup converts all non-alphanumeric characters pulled from the database (such as arrows or Greek letters) into question marks. Which is, obviously, unacceptable.</p>
  
  <p>I tried multiple solutions: specified the JDBC URL as <code>jdbc:mysql://localhost:3306/&lt;database&gt;?useUnicode=yes&amp;amp;characterEncoding=utf8</code>, played with <code>my.ini</code> file (and MySQL Workbench) to force everything in the database to default to <code>utf8</code> charset, and something that caused the largest headache: adding <code>&lt;property name="connectionProperties" value="useUnicode=yes;characterEncoding=utf8" /&gt;</code>. Turns out, it's literally impossible to set two connectionProperties within a single bean, because... there is no separating character mentioned anywhere (the bean will attempt to read it as trying to set <code>yes;characterEncoding=utf8</code> as the value of <code>useUnicode</code>). So my question is: how does I utf8?</p>