Gary Kindel Gary Kindel - 2 months ago 15
Java Question

Why is this string: javax.sql.rowset.serial.SerialClob being included in an output file instead of the actual value

I am using Mirth 3.1.0.x, to extract data from a Sql Server 2012 database and write the resultset to a flat file.

The code was working prior to a new column being added.

Here is the code in a transformer script for a Mirth Channel destination:

var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sqlserver://10.10.1.74:1433/rRIS_California','rRIS_California','rRIS_California');
var result1 = dbConn.executeCachedQuery("exec [z_SelectChannelData] 'AAI'");

while(result1.next())
{
tmp.row += <row>
<LastName>"{result1.getString('LastName')}"</LastName>
<FirstName>"{result1.getString('FirstName')}"</FirstName>
<HomePhone>"{result1.getString('HomePhone')}"</HomePhone>
<MRN>"{result1.getString('MRN')}"</MRN>
<EncounterID>"{result1.getString('EncounterID')}"</EncounterID>
<Accession>"{result1.getString('Accession')}"</Accession>
<Modality>"{result1.getString('Modality')}"</Modality>
<Procedure>"{result1.getString('ProcedureCode')}"</Procedure>
<Location>"{result1.getString('Location')}"</Location>
<PreferredLanguage>"{result1.getString('PreferredLanguage')}"</PreferredLanguage>
<Gender>"{result1.getString('Gender')}"</Gender>
<EmailAddress>"{result1.getString('EmailAddress')}"</EmailAddress>
<MobilePhoneNumber>"{result1.getString('MobilePhoneNumber')}"</MobilePhoneNumber>
<Room>"{result1.getString('Room')}"</Room>
<billing_code>"{result1.getString('billing_code')}"</billing_code>
<copay>"{result1.getString('copay')}"</copay>
</row>;
}
dbConn.close();


In the file out, the last column is not being populated by the actual value but the following string:

"copay"

"javax.sql.rowset.serial.SerialClob@1b795929"

"javax.sql.rowset.serial.SerialClob@5693cfb7"

Below, is the T-SQL for the last column:

Select
CASE WHEN v.copay is null THEN '' WHEN v.copay =0 THEN '' ELSE cast(v.copay as varchar(max)) END as copay
FROM <table> as v

Answer

Found the answer thanks to Evan Knowles and kucing_terbang. I was chasing the wrong rabbit. Issue caused by data type of the copay column. I was using varchar(max) because I was unsure how large the field might be. Changed it to varchar(20). Getting the correct value in the flat file.

SELECT
CASE WHEN v.copay is null THEN '' WHEN v.copay =0 THEN '' ELSE cast(v.copay as varchar(20)) END as copay
FROM <table> v