cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
250
Views
0
Helpful
2
Replies
Highlighted
Beginner

Java AXL ExecuteSQL returning row:null

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());
}
Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: Java AXL ExecuteSQL returning row:null

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

View solution in original post

2 REPLIES 2
Highlighted
Cisco Employee

Re: Java AXL ExecuteSQL returning row:null

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

View solution in original post

Highlighted
Beginner

Re: Java AXL ExecuteSQL returning row:null

Thank You! It work perfectly and I appreciate the help. I have been staring at my code for 3 days. I guess need to brush up on my Java web services.
This widget could not be displayed.