03-09-2020 10:56 AM
I am trying to return results from a query and the data is null. I get the correct amount of rows for the data being returned, but the text data is null. When I change the code to print the length of the data, it is always 0. When I log into the CUCM API directly and do a "run sql" data comes back. Any help would be appreciated.
ExecuteSQLQueryReq query = new ExecuteSQLQueryReq();
// Prepare a ListUserRes object to receive the response from AXL
ExecuteSQLQueryRes getSQLResponse;
// Set the query
query.setSql("select pkid from enduser");
try {
getSQLResponse = axlPort.executeSQLQuery(query);
user_list = getSQLResponse.getReturn().getRow();
} catch (Exception e) {
}
for (int x = 0; x < user_list.size(); x++) {
Element el = (Element)user_list.get(x);
System.out.println(el.getElementsByTagName("row").getLength());
//System.out.println(el.getElementsByTagName("row").item(x).getFirstChild().getTextContent());
}
Solved! Go to Solution.
03-10-2020 01:08 PM
I was able to get this working as below:
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
...
// Create an iterator to cycle through each row, below Iterator<Object> itr = user_list.iterator(); // While the iterator indicates there is at least one more row... while ( itr.hasNext() ) { // The individual row object is of this ElementNSImpl type - we'll need to cast from generic Object here ElementNSImpl el = ( ElementNSImpl )itr.next(); // Print out the formatted name and pkid values System.out.println( "Name: " + String.format( "%-20s", el.getElementsByTagName( "name" ).item( 0 ).getTextContent() ) + "PKID: " + el.getElementsByTagName( "pkid" ).item( 0 ).getTextContent() ); }
Added to the collection of samples here: https://github.com/CiscoDevNet/axl-java-samples
03-10-2020 01:08 PM
I was able to get this working as below:
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
...
// Create an iterator to cycle through each row, below Iterator<Object> itr = user_list.iterator(); // While the iterator indicates there is at least one more row... while ( itr.hasNext() ) { // The individual row object is of this ElementNSImpl type - we'll need to cast from generic Object here ElementNSImpl el = ( ElementNSImpl )itr.next(); // Print out the formatted name and pkid values System.out.println( "Name: " + String.format( "%-20s", el.getElementsByTagName( "name" ).item( 0 ).getTextContent() ) + "PKID: " + el.getElementsByTagName( "pkid" ).item( 0 ).getTextContent() ); }
Added to the collection of samples here: https://github.com/CiscoDevNet/axl-java-samples
03-11-2020 05:26 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide