title: Encoding issue on WebSphere 8.5.5.14 for a Java Application - XML parsing: line 1, character 39, unable to switch the encoding
body: <p>I have this setup in my local and i am facing this error as part of inserting an xml string to an xml type column in sql table. Please review this and share your thoughts to resolve this issue.</p>
  
  <p><strong>NOTE</strong>: I am using SAXBuilder for xmldocument and used format.setEncoding("UTF-16") before passing that xml document as parameter.
  Also to note, i dont see any such issue when i run my application using tomcat 8 and 9. I am seeing this issue only when i have integrated with WebSphere.</p>
  
  <p><strong>Server</strong>: Websphere Application Server 8.5.5.14
  <strong>SQL Server</strong>: 2014
  <strong>JDBC used</strong>: sqlJdbc41.jar and sqljdbc4.jar
  <strong>Targetted IBM JDK used</strong>: jdk1.7_64</p>
  
  <p><strong>Error Details</strong>:</p>
  
  <pre><code>Cause SQL Exception Info for exception at level 0 - SQL State: 'S0001'; SQL Error Number: '9402'; SQL Error Text: 'XML parsing: line 1, character 39, unable to switch the encoding
  
  com.microsoft.sqlserver.jdbc.SQLServerException: XML parsing: line 1, character 39, unable to switch the encoding
  
  at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1295)
  at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:836)
  </code></pre>
  
  <p>Tried the following options and i did not help.</p>
  
  <ol>
  <li><p>Updated WebSphere\AppServer\Properties\encoding.properties (WAS) file to keep this entry en=ISO-8859-1 as  en=UTF-8.</p></li>
  <li><p>Also tried the above with UTF-16 as well.</p></li>
  <li><p>Tried to update the following in JVC generic arguments as well.
  -Dclient.encoding.override=UTF-8
  -Dfile.encoding=UTF-8</p></li>
  </ol>
  
  <p>Since my application working with tomcat, so i did not expect to change any code to correct the xml string by using CAST / or passing the xmlstring with prefix N'xxxmlxx'. I will be trying this code change as well shortly. Meanwhile any other thoughts would really help.</p>
  
  <p>Do i need to try with latest jdbc jar (mssql-jdbc-6.2.2.jre7.jar)?
  Do i need to try with websphere bundled sdk 1.8?</p>