Package com.softwareag.tamino.db.api.connection

Provides classes and interfaces to establish connections and manage transactions.

See: Description

Package com.softwareag.tamino.db.api.connection Description

Provides classes and interfaces to establish connections and manage transactions.

This package is the starting point for each user of the Tamino API for Java. The first thing you have to do, is to acquire a TConnection instance via the TConnectionFactory class. A TConnection represents a session to a particula Tamino database indicated by a URL like http://host/tamino/myDB.

A TConnection instance serves as a factory for accessors. An accessor is always bound to a the TConnection instance it was created by, and is therefore also bound to the Tamino database for which the TConnection instance was created.

A TConnection instance is also used to determine the transaction mode in which Tamino database operations will be performed. There are two transaction modes available: the autocommit mode and the local transaction mode. When acquiring a new TConnection instance, it is automatically in autocommit mode. You can switch to local transcation mode by the useLocalTransactionMode method and back to autocommit mode by the useAutoCommitMode method. In autocommit mode, each Tamino database operation is automatically contained in its own transaction and Tamino will automatically commit each transaction if the operation succeeds. In local transaction mode, more than one Tamino database operation can be combined in one transaction. You can set the transaction boundaries explicitly by the TLocalTransaction interface. A local transaction is bound to a TConnection instance. Therefore, if you switch to local transaction mode, all accessors created by that TConnection instance are affected, i.e. the database operations triggered by any of these accessors will be done in the scope of the local transaction.

If a TConnection instance is no longer of use, it should be closed by the close method. All resources required for the database session will be relinquished. Once a TConnection instance is closed it can no longer be used.

The following code snippet shows how you can work with this package:

    
    TConnectionFactory connectionFactory = TConnectionFactory.getInstance();
    TConnection connection = connectionFactory.newConnection( databaseURI , userId , password );
    TXMLObjectAccessor xmlAccessor = connection.newXMLObjectAccessor( accessLocation , TDOMObjectModel.getInstance() );
    TLocalTransaction localTransaction = connection.useLocalTransactionMode();
    // Now the xmlAccessor can be used within a local transactional context
    ...
    localTransaction.commit();
    ...
    connection.close();
    
  

Copyright (c) 2017 Software AG. All Rights Reserved.