title: Postgres: org.postgresql.util.PSQLException: ERROR: insufficient data left in message
body: <p>I read enough to know that this occurs when a string contains some characters that Postgres doesn't like. However, I cannot figure out if there is a way to validate strings before writing them. In particular, I'm doing batch inserts. </p>
  
  <pre><code>insert into foo(col1,col2,col3) values ('a',2,3),('b',4,0),....
  </code></pre>
  
  <p>My DB is setup like this:</p>
  
  <pre><code>   Name     | Owner  | Encoding | Collate | Ctype | Access privileges
  ------------+--------+----------+---------+-------+-------------------
   stats      | me     | UTF8     | C       | C     |
  </code></pre>
  
  <p>Periodically, some bad string will get in and the whole insert will fail(e.g. <code>changeï¿½ï¿½ï¿½=</code>). I batch up quite a few values in a single insert so I'd like to ideally validate the string rather than bomb the whole insert. Is there a list of which characters are not allowed in a Postgres insert?</p>
  
  <p>Using postgresql-jdbc 9.1-901.jdbc4 </p>