Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

tJava returning array of Strings

I have a Java class that returns array of strings and I would like to write the values of the array elements to a database table.
For example tJava creates an array:
a = 'test1'
a = 'test2'
a = 'test3'
a = 'test4'
a = 'test5'

and I would like to insert all of these values in separate rows in a table.
Is this possible with TOS?
Thanks
Magi
Labels (3)
8 Replies
Anonymous
Not applicable

Hi
If you want to insert the values into table, you can use the tJavaRow component and add new columns.
Best regards
shong
_AnonymousUser
Specialist III
Specialist III
Author

Thank, but I think that it wouldn't work because the number of array elements is not know at design time and because I need one new column that contains all the values of the array and not one column for each value.

Magi
Anonymous
Not applicable

This is the purpose of the tForEach component.
Regards,
_AnonymousUser
Specialist III
Specialist III
Author

OK, I can connect my tFileList component to a tForEach component, but then I cannot connect my tForEach component to tJavaRow. Can you please explain how should they be connected?
The scenario is the following:
For a list of files I am executing a piece of Java that returns an ArrayList. So, if I have 10 files I have to execute the Java code 10 times and get 10 ArrayLists that need to be merged then in one list and put in a DB table.
Thanks
Magi
Anonymous
Not applicable

Here is a simple job doing this process.
I'm maybe wrong in the tJavaRow but I'm sure you understand your process more than me ;-)
Regards
_AnonymousUser
Specialist III
Specialist III
Author

Thanks, this helped but not enterely.
When I say merging, I in fact think of merging the arraylists.
If i have 3 files, there will be 3 array lists generated.
For example,
for file1 I get
a = 'test1'
a = 'test2'
a = 'test3'
a = 'test4'
a = 'test5'
for file 2 I get
b = 'testing1'
b = 'testing2'
b = 'testing3'
and for file 3 I get

c = 'tst1'
c = 'tst2'
c = 'tst3'
c = 'tst4'

What I want to get are the following rows in the mysqltable:
column1
'test1'
'test2'
'test3'
'test4'
'test5'
'testing1'
'testing2'
'testing3'
'tst1'
'tst2'
'tst3'
'tst4'
I hope this explains the problem better. Can you plese look into this?

Thanks
Magi
Anonymous
Not applicable

In the tJavaRow, add a separator between the myString in the mergedString :
mergedString+=myString+",";
and add a tNormalize after the tJavaRow.
Regards,
Anonymous
Not applicable

Many Thanks
I tested this and it works fine.
Magi.