Clob field not coming back in DB requests

Poster Content
nk4um User
Posts: 16
November 24, 2011 21:07

Many thanks cj.

Bit clunky, but i guess jtds do it for optimisation reasons.

I just changed it to use the MS driver and that seems ok (for now)

nk4um User
Posts: 159
November 24, 2011 09:58

This is happening because the NetKernel RDBMS module generates an HDS representation made up of the POJOs that are returned by the JDBC API. The default serialization of HDS, I believe, outputs the toString of the representation class (which in this case is a net.sourceforge.jtds.jdbc.ClobImpl). It looks like ClobImpl doesn't have a toString implementation, so uses the default Java one (which returns the Object's class and hash). If traverse the HDS in Java, you will get access to the actual Clob Object.

I can see two possible/sane solutions:

  • Processing the HDS after the query is performed, converting the Clob into a String.class.
  • Creating a Clob to String transreptor.

-cc

nk4um User
Posts: 16
November 23, 2011 22:59Clob field not coming back in DB requests

Im doing a db request using freemarker and jdts driver.

<#if component = "article-full">
select top 1 headline, articleBody
from PCA_Features f
</#if>

For some reason the articleBody which is nvarchar(max) comes back as a reference and not the field value.

[

    {
        "headline": "Boeing Designs In-Flight Surfing",
        "articleBody": "net.sourceforge.jtds.jdbc.ClobImpl@42ecf8c4"
    }

]

any ideas?

My config file for the RDBMS looks like

<config>
  <rdbms>
    <jdbcDriver>net.sourceforge.jtds.jdbc.Driver</jdbcDriver>
    <jdbcConnection>jdbc:jtds:sqlserver://localhost:1433/dev_live_sites;user=sa;password=xxxxxxx;</jdbcConnection>
    <poolSize>8</poolSize>
    <defaultQueryTimeout>5000</defaultQueryTimeout>
    <queryTimeoutMethod>SET | TIMER</queryTimeoutMethod>
    <connectionTestQuery />
    <connectionTestOnAcquire>false</connectionTestOnAcquire>
    <connectionTestOnIdlePeriod>60000</connectionTestOnIdlePeriod>
  </rdbms>
</config>