How to gettablenames of a serverconnection

when I use

var tableNamesArray =databaseManager.getTableNames('user_data');
var firstTableName = tableNamesArray[0];

I always get : ```
[Ljava.lang.String;@fa3bb0


I tried several existing database connections.

what doesn’t work for you then?

var tableNamesArray =databaseManager.getTableNames('user_data'); 
var firstTableName = tableNamesArray[0];
application.output(firstTableName)

gives me exactly the name of the first table found..

In my case the output is null
and the tableNamesArray gives a ```
[Ljava.lang.String;@9d6d87

that’s very strange then it looks like you have an empty array.. so no table name is returned..

do you have anything in the .log.txt file after you call it?

if you test:

application.output(tableNamesArray[1]);

or

application.output(tableNamesArray.length);

Never mind…
I restarted Servoy…
user_data has no tables and at first it returned null…and now it returns nothing.
Tried it with other connections and now it works…but yesterday it didn’t…got some funny voodoo shit going on here :roll:

Either way…it’s working now

var TabelNaamArray = databaseManager.getTableNames(controller.getServerName());
var y=TabelNaamArray.getMaxRowIndex();
for (i=0;i<y;i++)
{
controller.newRecord();
tabellenid=TabelNaamArray[i];
}

TabelNaamArray gets all tablenames but I got an other problem:
The method stops dead in his tracks at line 2.
Isn’t TabelNaamArray.getMaxRowIndex() the correct way to find out how many rows an array contains??
The error description:

Java class "[Ljava.lang.String;" has no public instance field or method named "getMaxRowIndex".

In the log.txt it says:

org.mozilla.javascript.EvaluatorException: Java class "[Ljava.lang.String;" has no public instance field or method named "getMaxRowIndex".org.mozilla.javascript.EvaluatorException: Java class "[Ljava.lang.String;" has no public instance field or method named "getMaxRowIndex".

please see example
it is an array what you get back to get the length of the array you have to do: array.length (so not getMaxRowIndex)

OK…it works…
but I’m confused…
I got this code somewhere from the forum:

var Groups = security.getGroups(); 
var showArray = new Array(Groups.getMaxRowIndex()); 

for ( var i = 0 ; i < Groups.getMaxRowIndex() ; i++ ) 
showArray[i] = Groups.getValue(i + 1, 2);

I assumed that getGroups would also create an array. Obviously it is not an array. What is it then?

i don’t know why so many people are confused by this (you are not alone)
because it is so displayed as good as we can do it in the method editor..

if you select Security.getGroups() in youre editor.. what do you see in the status line? Of what does the tooltip of getGroups() say?

that it returns a JSDataSet.. for example if you go to JSDataSet self. (child of Security node, and you select getColumnAsArray() you see that that one returns an array (Object)

JSDataSet can have multiple columns over many rows. And an array has one column.

Sorry…dude…
but hey what can I say…
do you read the manual of your VCR?? :lol:

I’m getting trained soon by one of you…so I’ll hope…no more dumb questions from me :shock:

no problem (my reply wasn’t meant to be aggressive in any way) but I was just stumped that many developers are mixing up an array and jsdataset.. :(

It’s a question that comes up quite often..