Search code examples
sql-serverwso2wso2-api-managerwso2-das

WSO2 AM 1.10.0: "The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."


I integrated wso2 am 1.10.0 (port offest 1) with wso2 das 3.0.1 (port offest 3), all seems ok, I can see usage data either from wso2am_stats_db or das carbon data explorer. I followed the instructions here to the word. However, each time I access any of apim publisher statistics page, I only saw stock image (SAMPLE: Config DAS to see yours), the the apim log spit out the following error:

TID: [-1234] [] [2016-09-15 03:11:21,634] ERROR {JAGGERY.modules.statistics.usage:jag} -  
org.wso2.carbon.apimgt.usage.client.exception.APIMgtUsageQueryServiceClientException: Error occurred while querying from JDBC databaseThe text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. {JAGGERY.modules.statistics.usage:jag}

I am using MSSQL database if that makes a difference. The script/schema is close to the one here. The error does not make sense to me as no text, ntext or image type was defined in the schema. See this discussion: The text, ntext, and image data > types cannot be compared or sorted, except when using IS NULL or LIKE > operator .


Solution

  • It took me some time to find out why the errors were thrown as our DDL has NO text data types for any of the columns, as you can tell from the SQL file mentioned above.

    Thanks for everyone's attention and time. It turns out this is the root cause: Very strange SQL Server behavior: automatically convert most varchar data types to text

    I understand this will not apply to others' case but I recorded it here just in case anyone runs into the same situation I did... Moral of the story: never trust the software you are using. In this case, even our DDL has no text data types, MSSQL somehow converted most of the varchar types to text in 5, 10 minutes or hours after we ran the DDL/SQL script to create those tables, in a random fashion.