IBM Support

WebSphere Adapter for JDBC V6.2 receives "unable to switch the encoding, error code:9402" message when calling stored procedure on Microsoft SQL Server 2005 database

Troubleshooting


Problem

You receive an error message when you call a stored procedure hosted on a Microsoft SQL Server 2005 database from a WebSphere Enterprise Bus V6.2 mediation using WebSphere Adapter for JDBC V6.2.

Symptom

You call a stored procedure hosted on a Microsoft SQL Server 2005 database from a
WebSphere Enterprise Service Bus V6.2 mediation using WebSphere Adapter for JDBC 6.2. The stored procedure takes a string argument with a serialized data object in XML format . An example is attached below:


<?xml version="1.0" encoding="UTF-8"?>
<p:EventData xsi:type="p:EventData" xmlns:xsi="http://www.w3. org/2001/XMLSchema-instance" xmlns:p="http://www.timetrade.com/ws"&gt;
<eventDate>2009-08-06T22:12:19.951Z</eventDate>
:
:
: data omitted
:

:
</p:EventData>


You receive the following error message:

ResourceException thrown in J2CMethodBindingImpl.invoke() javax.
resource.ResourceException: [IBM][SQLServer JDBC Driver][SQLServer]XML
parsing: line 1, character 38, unable to switch the encoding, error
code: 9402

If you manually change the UTF encoding from "UTF-8" to "UTF-16" in the serialized XML, the stored procedure works.

If you use the SQL server tools to call the same stored procedure, it fails with UTF-16 and only accepts UTF-8.

Cause

This issue is caused by the Microsoft SQL Server database storing UTF-8 data, and is not a JDBC Adapter related issue.

Resolving The Problem

The behavior is specific to the Microsoft SQL Server database server, and is not a JDBC Adapter problem.

To resolve the issue, refer to the following document from Microsoft:
Description of storing UTF-8 data in SQL Server: http://support.microsoft.com/kb/232580

[{"Product":{"code":"SSMKUK","label":"WebSphere Adapters Family"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Adapter for JDBC","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"6.2","Edition":"WebSphere","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
15 June 2018

UID

swg21398797