title: Unknown initial character set index '255' received from server
body: <p>During attempt to create HibernateSession application fails with exception:</p>
  
  <blockquote>
    <p>Caused by: java.sql.SQLException: Unknown initial character set index
    '255' received from server. Initial client character set can be forced
    via the 'characterEncoding' property.     at
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)    at
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)     at
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)</p>
  </blockquote>
  
  <p>I found one possible solution <a href="https://stackoverflow.com/questions/43991101/re-introduced-unknown-initial-character-set-index-error">here</a> but unfortunately I do not have access to DB server thus I cannot change its configuration. 
  <em>So please pay attention that this is not a duplicate, because suggested solution was provided for the DB server changes and in my case I don't have such access.</em></p>
  
  <p>Is it any chance to fix this issue on client side? Below you can find my pom.xml file and java code where I create session.</p>
  
  <pre><code>import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  public class HibernateUtil {
      private static final SessionFactory sessionFactory = buildSessionFactory();
  
      private static SessionFactory buildSessionFactory() {
          try {
              // Create the SessionFactory from hibernate.cfg.xml
              return new Configuration().configure().buildSessionFactory();
          } catch (Throwable ex) {
              // Make sure you log the exception, as it might be swallowed
              System.err.println("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  
      public static void shutdown() {
          // Close caches and connection pools
          getSessionFactory().close();
      }
  }
  </code></pre>
  
  <p>And my pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      ...
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.6&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.5.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.testng&lt;/groupId&gt;
              &lt;artifactId&gt;testng&lt;/artifactId&gt;
              &lt;version&gt;6.9.12&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt; 
  </code></pre>