jeudi 18 juin 2015

Java document.db.query into arraylist

I am struggling to get my sql database to populate these results, my Document is:

ArrayList<HashMap<String, String>> queryList = new ArrayList<HashMap<String, String>>();
doc = db.query("SELECT blah, blah FROM table WHERE PDA_IMEI ='"+IMEI+"'");

this is then converted into an array list:

queryList = db.getList(doc);

get list is a function which gets the nodes etc

public ArrayList<HashMap<String, String>> getList(Document doc) {
    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

    NodeList nodes = doc.getElementsByTagName("result");
    Node child;

    for (int i = 0; i < nodes.getLength(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();

        Element e = (Element) nodes.item(i);

        for (child = e.getFirstChild(); child != null; child = child
                .getNextSibling()) {
            map.put(child.getNodeName(), child.getTextContent());
        }

        mylist.add(map);
    }

    return mylist;
}

but for some reason my doc statement when moving into the array list the size is 0.

I know its the code as i have got the URL Query and this populates the result so the connection is there

Aucun commentaire:

Enregistrer un commentaire