Get a respose from the database

Hello out there,
I would like to get some response from the database while I’m putting data into it.

TXMLObject tobj = TXMLObject.newInstance ( mydoc);
	
	try {
	TConnection connection = TConnectionFactory.getInstance().newConnection( "http://localhost/tamino/chris" );
	TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor(
            TAccessLocation.newInstance( "ino:etc" ),
            TJDOMObjectModel.getInstance() );
	myret = xmlObjectAccessor.insert( tobj );
	connection.close();
	} catch ( TConnectionException te ) { te.getCause(); }  
	  catch ( TInsertException ie ) { ie.toString(); };
	
	out.println(" Creating now an XML object ");
	out.println("the return value is:" + myret.getReturnValue() + "</p>");
	out.println("</BODY></HTML>");

with myret I would like to get some feetback if the transaction was succesfull. But I got only the message:

What can I do here?

Gruss Christian

This is a java compiler error. It is generated because you have referenced the myret variable outside the try block, and the variable only ever receives a value inside the try block. It is possible to get to the referencing code without going through the “insert” code, and in that case, the variable will not be initialized. To fix the error, move the referencing code inside the try block (for example, immediately following the insert statement).

Hey Bill, thank you. Now it works.

I changed the code this way

[quote]
try {
TConnection connection = TConnectionFactory.getInstance().newConnection( “http://localhost/tamino/chris” );
TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor(
TAccessLocation.newInstance( “ino:etc” ),
TJDOMObjectModel.getInstance() );
TResponse myret = xmlObjectAccessor.insert( tobj );
out.println(" Erzeuge jetzt ein XML-Objekt aus diesen Daten ");
out.println("Die R

Hi Christian,
As far as I understand it, if the TResponse method “getReturnValue()” returns zero, the insert worked.

I think that the Tamino APIs check the response message for any non-zero ino:returnvalue and will return that value to indicate an error.

If the return value is zero then the operation should have succeeded.

Yes, but we need this information what is the meaning of the non-zero values, to insert this in our Servlet. I want to enable the servlet to put out readable errorcode, if something goes wrong. That is my intention!

Gruss Christian

Hello Christian,

If there is a problem an TInsertException exception is thrown. And you may use the APIs provided by TInsertException object to fetch the errorcode and the error message for the purpose.

Hope this answers to your query.

All the Best.

Regards,

Abhijeet