getTotalCount once again!

Hello!

I have not solved yet my problem to get record count to mydb tamino. I tried in this way:

---------------------------------------
import java.util.;
import org.w3c.dom.
;
import com.softwareag.tamino.api.dom.*;

public class count {
public static final void main(String arg[]) throws Exception {
TaminoClient tc = new TaminoClient(“http://localhost/tamino/mydb/col”);
tc.setPageSize(0);
tc.startSession();
try {
TaminoResult tr = tamino.query(“count(/doc[id_client=‘12345’])”);
Element el = tr.getElement();
System.out.println(“GET_TAG_NAME=” +el.getTagName());
System.out.println(“TO_STRING=” +el.toString());
System.out.println(“PRINT_TREE=”);
tc.printTree(el);
tc.endSession();
}
catch (com.softwareag.tamino.api.dom.TaminoError Error)
{
System.err.println(
"Tamino Error Code: " + Error.responseCode + “\n” +
"Tamino Error Text: " + Error.errorText);
}
}
}
---------------------------------------
The following output text I got:

GET_TAG_NAME=xql:result
TO_STRING=xql:result9</xql:result>
PRINT_TREE=
–xql:result
?–#text 9
---------------------------------------

How can I get the text ONLY value 9?

Please help me!

Any help will be very appreciated!

Thanks in advance!

best regards,
Dariusz Baumann

I tried in this way:
------------------------------------------------
import java.util.;
import org.w3c.dom.
;
import com.softwareag.tamino.api.dom.*;

public class count {
public static final void main(String arg[]) throws Exception {
TaminoClient tamino = new TaminoClient(“http://localhost/tamino/mydb/col”);
tamino.setPageSize(0);
tamino.startSession();
try {
TaminoResult tr = tamino.query(“count(/doc[id_client=‘12345’])”);
Element el = tr.getElement();
System.out.println(“GET_NODE_NAME=” +el.getNodeName());
System.out.println(“GET_NODE_VALUE=” +el.getNodeValue());
tamino.endSession();
}
catch (com.softwareag.tamino.api.dom.TaminoError Error)
{
System.err.println(
"Tamino Error Code: " + Error.responseCode + “\n” +
"Tamino Error Text: " + Error.errorText);
}
}
}
------------------------------------------------
… but unfortunately, I got the following text message:

GET_NODE_NAME=xql:result
GET_NODE_VALUE=null

Please help me! Thanks a lot!

best regards,
Dariusz Baumann

The last my try was:
-----------------------------------------------
public class count {
public static final void main(String arg[]) throws Exception {
// TaminoClient tc = new TaminoClient(“http://localhost/tamino/mydb/col”);
tc.setPageSize(0);
tc.startSession();
try {
// TaminoResult tr = tc.query(“count(/doc[id_client=‘12345’])”);
Element el = tr.getElement();
System.out.println(“GET_NODE_NAME=” +el.getNodeName());
System.out.println(“GET_NODE_VALUE=” +el.getElementsByTagName(“xql:result”).item(0).getNodeValue());
tc.endSession();
}
catch (com.softwareag.tamino.api.dom.TaminoError Error)
{
System.err.println(
"Tamino Error Code: " + Error.responseCode + “\n” +
"Tamino Error Text: " + Error.errorText);
}
}
}
-----------------------------------------------
… but I got the following text:

GET_NODE_NAME=xql:result
Exception in thread “main” java.lang.NullPointerException at count.main(count.java:16)

Please help me! Thanks!

best regards,
Dariusz Baumann

el is a Text object. you need to type cast it and call its getData method.

System.out.println(“GET_TAG_NAME=” +el.getTagName());
System.out.println(“GETDATA=” +((Text)el).getData());
christian

I tried like you wrote but it doesn’t work! My code is:

--------------------------------------------------
import java.util.;
import org.w3c.dom.
;
import com.softwareag.tamino.api.dom.*;

public class count {
public static final void main(String arg[]) throws Exception {
TaminoClient tc = new TaminoClient(“http://localhost/tamino/mydb/col”);
tc.setPageSize(0);
tc.startSession();
try {
TaminoResult tr = tc.query(“count(/doc[id_client=‘12345’])”);
Element el = tr.getElement();
System.out.println(“GET_TAG_NAME=” +el.getTagName());
System.out.println(“GETDATA=” +((Text)el).getData());
tc.endSession();
}
catch (com.softwareag.tamino.api.dom.TaminoError Error)
{
System.err.println(
"Tamino Error Code: " + Error.responseCode + “\n” +
"Tamino Error Text: " + Error.errorText);
}
}
}
--------------------------------------------------

I got the following text:

GET_TAG_NAME=xql:result
Exception in thread “main” java.lang.ClassCastException: com.docuverse.dom.BasicElement at count.main (count.java:16)

Please help me! Thanks!

best regards,
Dariusz Baumann

Hi Dariusz,

the problem is that the value is stored within a child node:

    public static final void main(String arg[]) throws Exception {
	TaminoClient tc = new TaminoClient("http://localhost/tamino/mydb/col");
	tc.setPageSize(0);
	tc.startSession();
	try {
	    TaminoResult tr = tc.query("count(/doc[id_client='12345'])");
	    Element el = tr.getElement();

	    System.out.println("GET_TAG_NAME=" + el.getTagName());

	    Node elChild = el.getFirstChild();
	    System.out.println("GET_TAG_NAME=" + elChild.getNodeName());
	    System.out.println("GETDATA=" + elChild.getNodeValue());

	    tc.endSession();

	} catch (com.softwareag.tamino.api.dom.TaminoError Error) {
	    System.err.println("Tamino Error Code: " + Error.responseCode + "\n" +
			       "Tamino Error Text: " + Error.errorText);
	}
    }



Cheers,
Trevor.

Thanks a lot, Trevor Ford !
Now it works! :):slight_smile:

best regards,
Dariusz Baumann