One Star

XML encoding

I have created XML file which I am passing to SQL database as string.
Everything look ok unitl my string comming to the SQL database procedure as string where I am having error below.
Is anyone having an idea what can be. Also you can see an image of my work.
Exception in component tMSSqlSP_2
java.sql.SQLException: XML parsing: line 1, character 44, unable to switch the encoding
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.execute(
One Star

Re: XML encoding

From Microsoft - For other related posts do search on 'SQL server encoding'.
One Star

Re: XML encoding

I have been banging my head against the wall with the same issue loading raw XML into a MS SQL Server 2014 XML datatype column.
Changing the encoding of or removing the XML declaration line from the input file did not work.
Adding the following value to the jtds connection string ("Additional Parameters" option) worked.  The setting of source file encoding and the xml declaration are irrelevant.
jtds options:
Screenshot of Talend MS SQL Server jdbc Connection properties
Seven Stars

Re: XML encoding

FYI - I've also found using the AdditionalParams option of "sendStringParametersAsUnicode=false" useful when updating table data withe US default collation level of "SQL_Latin1_General_CP1_CI_AS".
Without this, it often ignores any indexes and performs a full table scan.


Don't forget to give Kudos when an answer is helpful or the solution.