Four Stars

Tmap NullPointerException when converting integer to string

I'm trying to convert integer to string datatype for a column which has some null values and the data gets loaded, but keep getting java.lang.NullPointerException in my Run window.  What causes this even the data is loaded to the output table?

 

Doing conversion in tmap using Relational.ISNULL(row1.column)?nullSmiley Frustratedtring.valueOf(row1.column) 

In Tmap, output column is selected as string.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Nine Stars

Re: Tmap NullPointerException when converting integer to string

Make sure in your output ... the new column is able to except null values, so if its an existing table... make sure null is allowed. 

row1.column = null
String.valueOf(row1.column) will return "null"

 

try this:

row1.column==null ? null : ""+row1.column

or:

row1.column==null ? null : Integer.toString(row1.column)

 

6 REPLIES
Nine Stars

Re: Tmap NullPointerException when converting integer to string

Make sure in your output ... the new column is able to except null values, so if its an existing table... make sure null is allowed. 

row1.column = null
String.valueOf(row1.column) will return "null"

 

try this:

row1.column==null ? null : ""+row1.column

or:

row1.column==null ? null : Integer.toString(row1.column)

 

Four Stars

Re: Tmap NullPointerException when converting integer to string

I've tried both of these commands and it still gives me the same error.  

NOTE:  It does load null values to the output table, but the error still comes up in the run window.  Total # of input records matches the output load records.

Nine Stars

Re: Tmap NullPointerException when converting integer to string

Could you please attach your process flow... and also tmap ... Im positive something else is going wrong...
run window you mean console?
Twelve Stars

Re: Tmap NullPointerException when converting integer to string

@rp2018,try the below way. and let me know

 

 

(row1.col).toString()

Manohar B
Four Stars

Re: Tmap NullPointerException when converting integer to string

 Here are the screen shots of my job.  Yes, I'm getting the error message in the Run console.

 

Capture4.PNGCapture5.PNG

Nine Stars

Re: Tmap NullPointerException when converting integer to string

Looks absolutely fine... Are you sure your input table row1.column is of int type in the database table? and not a nvarchar(10) ? Could you put a logrow between input and tmap and also between tmap and output.

Note:
Some type conversion is taking place within java-code, int is a primitive type and cant be null, Integer is of object type and can be null.