title: Retrieving latin1 encoded results with JDBC
body: <p>I am trying to retrieve result sets from a MySQL database sing JDBC which is then used to generate reports in BiRT. The connection string is set up in BiRT.</p>
  
  <p>The database is latin1:</p>
  
  <pre><code>SHOW VARIABLES LIKE 'c%';
  +--------------------------+----------------------------+
  | Variable_name            | Value                      |
  +--------------------------+----------------------------+
  | character_set_client     | latin1                     | 
  | character_set_connection | latin1                     | 
  | character_set_database   | latin1                     | 
  | character_set_filesystem | binary                     | 
  | character_set_results    | latin1                     | 
  | character_set_server     | latin1                     | 
  | character_set_system     | utf8                       | 
  | character_sets_dir       | /usr/share/mysql/charsets/ | 
  | collation_connection     | latin1_swedish_ci          | 
  | collation_database       | latin1_swedish_ci          | 
  | collation_server         | latin1_swedish_ci          | 
  | completion_type          | 0                          | 
  | concurrent_insert        | 1                          | 
  | connect_timeout          | 5                          | 
  +--------------------------+----------------------------+
  </code></pre>
  
  <p>So I have been trying to correct the strange looking encoding results that are returned (German characters). I thought it would make sense to us the "characterSetResults" property to retrieve the result set as "latin1" like this:</p>
  
  <pre><code>jdbc:mysql://localhost:3306/statistics?useUnicode=true&amp;characterEncoding=latin1&amp;characterSetResults=latin1
  </code></pre>
  
  <p>This connection string fails and by deduction I have discovered that it is the property:</p>
  
  <pre><code>characterSetResults=latin1
  </code></pre>
  
  <p>is causing the connection to fail. The error is a long java error which means little to me. It starts with:</p>
  
  <pre><code>org.eclipse.birt.report.data.oda.jdbc.JDBCException: There is an error in get connection, Communications link failure
  
  Last packet sent to the server was 38 ms ago..
      at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.doConnect(JDBCDriverManager.java:262)
      at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.getConnection(JDBCDriverManager.java:186)
      at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.tryCreateConnection(JDBCDriverManager.java:706)
      at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.testConnection(JDBCDriverManager.java:634)
      at org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader.testConnection(DriverLoader.java:120)
      at org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader.testConnection(DriverLoader.java:133)
      at org.eclipse.birt.report.data.oda.jdbc.ui.profile.JDBCSelectionPageHelper.testConnection(JDBCSelectionPageHelper.java:687)
      at org.eclipse.birt.report.data.oda.jdbc.ui.profile.JDBCSelectionPageHelper.access$7(JDBCSelectionPageHelper.java:655)
      at org.eclipse.birt.report.data.oda.jdbc.ui.profile.JDBCSelectionPageHelper$7.widgetSelected(JDBCSelectionPageHelper.java:578)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
  </code></pre>
  
  <p>If I change this to:</p>
  
  <pre><code> characterSetResults=utf8
  </code></pre>
  
  <p>the connection string connects without errors, but the encoding issue remains. </p>
  
  <p>Does anyone know the correct way to retrieve latin1? And yes, I know UTF8 is the thing to use, but this is not my database....</p>
  
  <p>Thank you for reading this,
  Stephen</p>