I don't get getDataAsList. I've retrieved a DataRow which has stuff in it. I can grab the elements by name by using getItem on the DataRow. But getDataAsList returns null. Is that function broken?
BTW there are some null values in the DataRow--can that cause getDataAsList to break?
getDataAsList is broken?
There are 2 methods in the DataRow which are used internally:
getDataAsList()
getDataAsMap()
getDataAsList should be used only when your DataRow contains columns with numeric indexes. It returns a java.util.List
getDataAsMap should be used when your DataRow contains columns with string indexes. It returns a java.util.Map
(check my other response to your other DataRow-related post)
getDataAsList()
getDataAsMap()
getDataAsList should be used only when your DataRow contains columns with numeric indexes. It returns a java.util.List
getDataAsMap should be used when your DataRow contains columns with string indexes. It returns a java.util.Map
(check my other response to your other DataRow-related post)
It's not possible with the DbManager, you choose one of the two methods before executing the query. So you either get back a list or a map.
As I said in another post if you need more advanced interaction with the database you can use the getConnection() method (see the docs) and access the entire JDBC set of methods.
A few resources that might help:
http://www.cs.unc.edu/Courses/wwwp-s98/ ... c/183.html
http://www.onjava.com/pub/a/onjava/exce ... ndex1.html
As I said in another post if you need more advanced interaction with the database you can use the getConnection() method (see the docs) and access the entire JDBC set of methods.
A few resources that might help:
http://www.cs.unc.edu/Courses/wwwp-s98/ ... c/183.html
http://www.onjava.com/pub/a/onjava/exce ... ndex1.html
Re: getDataAsList is broken?
Hi!
Could you please explain me the following:
There is a table that consists of 4 fields, and a simple query: "select * from table_name"
List<DataRow> queryRes = (ArrayList<DataRow>)db.executeQuery(sqlStr, DataRow.DATAROW_INTKEY);
DataRow row = queryRes.get(0);
List <String> list = row.getDataAsList();
System.out.println("size = " + list.size());
for (int i = 0; i < list.size(); i++)
System.out.format("list[%d] = %s\n", i, list.get(i));
I I get the following:
size = 5
INFO | jvm 1 | 2016/11/16 18:00:18 | list[0] =
INFO | jvm 1 | 2016/11/16 18:00:18 | list[1] = 8
INFO | jvm 1 | 2016/11/16 18:00:18 | list[2] = 1
INFO | jvm 1 | 2016/11/16 18:00:18 | list[3] = 31796
INFO | jvm 1 | 2016/11/16 18:00:18 | list[4] = 1.1
My questions is:
Why the size of the list is wrong (5 instead of 4), and what is the very first an empty element in the list with index 0 ?
Thanks!
Could you please explain me the following:
There is a table that consists of 4 fields, and a simple query: "select * from table_name"
List<DataRow> queryRes = (ArrayList<DataRow>)db.executeQuery(sqlStr, DataRow.DATAROW_INTKEY);
DataRow row = queryRes.get(0);
List <String> list = row.getDataAsList();
System.out.println("size = " + list.size());
for (int i = 0; i < list.size(); i++)
System.out.format("list[%d] = %s\n", i, list.get(i));
I I get the following:
size = 5
INFO | jvm 1 | 2016/11/16 18:00:18 | list[0] =
INFO | jvm 1 | 2016/11/16 18:00:18 | list[1] = 8
INFO | jvm 1 | 2016/11/16 18:00:18 | list[2] = 1
INFO | jvm 1 | 2016/11/16 18:00:18 | list[3] = 31796
INFO | jvm 1 | 2016/11/16 18:00:18 | list[4] = 1.1
My questions is:
Why the size of the list is wrong (5 instead of 4), and what is the very first an empty element in the list with index 0 ?
Thanks!
Re: getDataAsList is broken?
Hi,
column indexes start at index = 1, so you can simply ignore index = 0.
cheers
column indexes start at index = 1, so you can simply ignore index = 0.
cheers
Re: getDataAsList is broken?
Let me pay your attention.
It's absolutely inappropriate behaviour!
Arrays indexes always begin at index = 0, so why column indexes have to start at index=1??? It's a mess!
And we've got a stupid empty element in a column List and a discouraging wrong array size as a "bonus"..
......
It's absolutely inappropriate behaviour!
Arrays indexes always begin at index = 0, so why column indexes have to start at index=1??? It's a mess!
And we've got a stupid empty element in a column List and a discouraging wrong array size as a "bonus"..
......
Re: getDataAsList is broken?
You can always write your own JDBC code and totally bypass the server's API, if you so desire.
cheers
cheers
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 33 guests