title: inserting String value of byte array in mysql database
body: <p>I have a byte array as shown below,</p>
  
  <pre><code>byte b1[] = {-127, -87, -32, -112};
  </code></pre>
  
  <p>when I'm trying to convert it to a String it's showing black diamond like character, I want to insert it in the database.</p>
  
  <p><strong>Which charset should I use for database?</strong></p>
  
  <p>I have tried <code>utf8mb4</code> and <code>CP1250</code>? I'm using <code>mysql version 5.7.14</code> ?</p>
  
  <p>Given below error while inserting:</p>
  
  <pre><code>java.sql.SQLException: Incorrect string value: '\xEF\xBF\xBD\xEF\xBF\xBD...' for column
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>   byte b1[] = {-127, -87, -32, -112};
     TRNRequest tr = new TRNRequest();
     tr.set(new String(b1));
     trnRequestService.saveTransactionRequest(tr);
  </code></pre>
  
  <p><code>trnRequestService</code> is <em>dao layer service</em> which stores object in database and <code>TRNRequest</code> is my class, I am using <em>Hibernate</em> for database connection. I want to read this character</p>
  
  <pre><code>public class DbByteInsert {
          public static void main(String[] args) {
               System.out.println(new String(new byte[]{ 48, 50}));
               System.out.println(new String(new byte[]{ -127, -87, -32, -112}));
          }
  }
  </code></pre>
  
  <p>check this example I am able to insert first byte array in db but I can not insert second..!</p>