I am using sourceforge JDBC driver for MS SQL database to read data and then process it.
This is how data read looks like:
def calculateHashedMessages() {
log.info('CalculatedHashedMessages')
def hashedMessages = [:]
def digestCalculator = MessageDigest.getInstance("SHA-1")
db.eachRow("""
select top 1000 phone, text, id
from proxyTable
where dlr_description is null
and processed_at is null
and hashed is null
""") { row ->
hashedMessages[row['id']] = calculateHashForRow(row, digestCalculator)
}
hashedMessages
}
And then phone and text are processed in following way:
def calculateHashForRow(row, digestCalculator) {
log.info('calculateHashForRow')
log.info("PHONE: ${row['phone']} || TEXT ${row['text']}")
def phone = row['phone']
def text = row['text']
def token = "${phone}_${text}"
log.info("${token}")
digestCalculator.update(token.getBytes())
//(digestCalculator.digest()).toString()
new BigInteger(1, digestCalculator.digest()).toString(16).padLeft(40, '0')
}
But this doesn't work and by logging I found out that the following is forwarded to calculateHashForRow method:
PHONE: net.sourceforge.jtds.jdbc.ClobImpl@27d3bfc1
TEXT: net.sourceforge.jtds.jdbc.ClobImpl@3ed22c54
Can anyone tell me why this would be contained in row['phone'] and row['text'] instead of values that are inserted in database?
P.S. this code is not entirely written by me and it actually works on different machine (with same settings) so I am a bit confused why it wouldn't work here.
Try