Hello Arunkumar,
You cannot call toString method on a NULL value, you can only do it when
there is a real object assigned to the variable (unless Scala or whatever
language you are using has some special treatment for such situation). Try:
while (ds.next()) {
val row:Row= ds.getRow()
val column1= row.getValue(0)
val column2= row.getValue(1)
if (column1 != null) {
val column1StrVal = column1.toString
}
if (column2 != null) {
val column2StrVal = column2.toString
}
}
BTW I also fixed indexes in the getValue calls - there were two times 0. I
hope that helps!
Pozdrawiam / Regards / Med venlig hilsen
Tomasz Guziałek
2015-11-25 5:59 GMT+01:00 Arunkumar Pillai <[email protected]>:
> Hi
>
> I'm using select query to fetch records and my code is as follows
>
> val connection = DB.getConnection()
> val dataContext:DataContext =
> DataContextFactory.createJdbcDataContext(connection)
> var query:Query =
>
> dataContext.query().from("TABLE_NAME").select("COLUMN1").select("COLUMN2").toQuery
>
>
> val ds:DataSet= dataContext.executeQuery(query)
>
> while (ds.next()) {
> val row:Row= ds.getRow()
> val column1= row.getValue(0).toString
> val column2= row.getValue(0).toString
>
> }
>
>
>
> if any of the value is NULL then it breaks there. Any suggestions or help
> would be highly appreciated.
>