Tamino TConnection Exception

Can anybody tell me how to avoid this error:

unreported exception com.softwareag.tamino.db.API.connection.TConnectionException.
I use jsdk1.4.1_01

Here is my code:

Class Knjiga.java:

import com.softwareag.tamino.db.API.accessor.TXMLObjectAccessor;
import com.softwareag.tamino.db.API.accessor.TQuery;
import com.softwareag.tamino.db.API.accessor.TQueryException;
import com.softwareag.tamino.db.API.accessor.TAccessorException;
import com.softwareag.tamino.db.API.accessor.TSystemAccessor;
import com.softwareag.tamino.db.API.accessor.TInsertException;
import com.softwareag.tamino.db.API.accessor.TDeleteException;
import com.softwareag.tamino.db.API.accessor.TAccessLocation;
import com.softwareag.tamino.db.API.common.;
import com.softwareag.tamino.db.API.connection.
import com.softwareag.tamino.db.API.objectModel.;
import com.softwareag.tamino.db.API.objectModel.jdom.
import com.softwareag.tamino.db.API.response.;
import org.jdom.
import org.jdom.input.;
import org.jdom.output.
import java.io.;
import java.util.

public class Knjiga {

private TConnection connection = null;
private TXMLObjectAccessor accessor = null;
public Knjiga(String databaseURI,String collection) throws TConnectionException {

TConnectionFactory connectionFactory = TConnectionFactory.getInstance();
connection = connectionFactory.newConnection( databaseURI );
accessor = connection.newXMLObjectAccessor(TAccessLocation.newInstance( collection ) ,TJDOMObjectModel.getInstance());

catch (TConnectionException terr)
System.err.println (“Sorry, database " + databaseURI + " is offline.”) ;
catch (TException terr)
System.err.println (“A Tamino Error was caught:”) ;
System.err.println (terr.getMessage()) ;
catch (Exception e)
System.err.println (“Application error”) ;
e.printStackTrace() ;

private TResponse processQuery(String s) throws Exception {
TQuery query = TQuery.newInstance( s );
try {
// Invoke the query operation
return accessor.query( query );
catch (TQueryException queryException) {
// Inform about the reason for the failure
return null;

private void showAccessFailure(TAccessorException accessorException)
throws Exception {

TAccessFailureMessage accessFailure = accessorException.getAccessFailureMessage();
if ( accessFailure != null )
throw new Exception( “Access failed:” + accessFailure );
throw new Exception(
“Access failed:” + accessorException.getMessage() );

void show(String keyValue) throws Exception {
try {
TResponse response =processQuery( “knjiga[oblast”+“='” + keyValue + “']” );
//TResponse response =processQuery( “knjiga[autor”+“~='” + keyValue + “']” );
//TResponse response =processQuery( “knjiga[ime_knjige”+“~='” + keyValue + “']” );
//TResponse response =processQuery( “knjiga[isbn”+“='” + keyValue + “']” );
//TResponse response =processQuery( “knjiga[izdavac”+“~='” + keyValue + “']” );
if (!response.hasFirstXMLObject()) throw new Exception(“Nothing found”);
TXMLObject xmlobject = response.getFirstXMLObject();

TXMLObjectIterator collabIt = response.getXMLObjectIterator();
while (collabIt.hasNext()) {
xmlobject= collabIt.next();
Element collab= (Element) xmlobject.getElement();
XMLOutputter outputter = new XMLOutputter();
outputter.output(collab, System.out);

catch (Exception e) {
throw e;
finally {
// Close the connection

Class Knjizara.java (main class):

import javax.swing.UIManager;
import java.awt.;
import java.awt.event.
import com.softwareag.tamino.db.API.accessor.TXMLObjectAccessor;
import com.softwareag.tamino.db.API.connection.*;

public class Knjizara implements ActionListener{
private boolean packFrame = false;
private final static String databaseURI = “http://localhost/tamino/knjizara”;
private final static String collection = “knjige”;
private KnjizaraUI frame1=null;
private Knjiga knjiga1 =new Knjiga(databaseURI, collection);
public Knjizara() {
KnjizaraUI frame1 = new KnjizaraUI(this);
if (packFrame) {frame1.pack();}
else {frame1.validate();frame1.setVisible(true);}}

public static void main(String args) throws Exception
{ new Knjizara(); }
public void actionPerformed(ActionEvent event)
{ String komanda=event.getActionCommand();
if (komanda.equals(“dugme1”))

String s= frame1.citaj();

When I put main method in class Knjiga it works properly, but if I make instance in class Knjizara, TConnection exception is generated.


Do you have a stack trace for the exception, and if so can you please post it here. Also can you please post the source code for KnjizaraUI?


Hi again.
These are compiler errors; not runtime errors.
You get them because:
1) When you instantiate your class Knjizara, its constructor creates an instance of Knjiga when it populates the variable:

private Knjiga knjiga1 =new Knjiga(databaseURI, collection);</pre><BR>The Knjiga constructor can throw an Exception, which is not caught in your Knjizara code. If you add "throws Exception" to the Knjizara constructor:<BR><pre class="ip-ubbcode-code-pre">public static void main(String[] args) throws Exception

the first error will go away.
2) Method knjiga1.show(s) can also throw an unhandled exception. So you need to put this in a try/catch block in Knjizara’s main method.

Hope this helps.

I tried to do it, but the error still exist

Please zip up all of your code (including the missing KnjizaraUI class) and attach it to a post.

I made some changes in code, so it works proper (for) now. I have just one question: does any method exist for displaying xml, for example:

Firstname: john

without using xsl? I tried to find it, but I didn’t have success.

Thanks for your help!

It’s great that you got your code to work, but in general if you manage to fix a problem by making code changes, it helps if you tell everyone what changes you made. That way, if someone else finds the same problem, they can apply the same solution. Thanks in advance. :slight_smile:

Your second question asks about displaying xml without using xsl. If you mean from a java program, you can do this by accessing the XML DOM for your document. In your case, you are using JDOM so, for example, you can write:

Element collab = (Element) xmlobject.getElement();
String value = collab.getChild("title").getText();

This code will get the child Element “title” of the root Element “collab”, and will put its value into a String (which you can write out or whatever you like). Hope this helps, but if I have misunderstood the question please post a new question on this topic - it’s not really connected to your original TConnectionException any more.
Thanks again.

I attach my source code so you can see what kind of changes I made (in class Knjiga and class Knjizara).

Which is the best way to relate class Knjiga and class Oblast? I want to display result of the query from class Knjiga in TextArea (variable result2) in class Oblast, but I don’t have any idea how to do it. I tried something but it didn’t work.

Thanks for your help! :wink:
KnjizaraUI.zip (5.25 KB)