You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ms...@apache.org on 2002/02/25 01:16:52 UTC

cvs commit: jakarta-slide/src/stores/slidestore/j2ee J2EEStore.java J2EEContentStore.java J2EEDescriptorsStore.java

msmith      02/02/24 16:16:52

  Modified:    src/stores/slidestore/j2ee J2EEContentStore.java
                        J2EEDescriptorsStore.java
  Added:       src/stores/slidestore/j2ee J2EEStore.java
  Log:
  Add J2EEStore (abstract class implementing all the shared XA methods used
  by the J2EEStores, plus some of the service methods and connection
  handling code.
  
  Modify the content and descriptors store to extend this new class, so
  we don't have as much duplicated code. Now the actual J2EEDescriptorsStore
  and J2EEContentStore _only_ implement the store methods directly - everything
  else is in their superclass, so these are essentially a mapping from slide
  store methods to jdbc statements, now.
  
  Content store is untested.
  
  Revision  Changes    Path
  1.4       +19 -283   jakarta-slide/src/stores/slidestore/j2ee/J2EEContentStore.java
  
  Index: J2EEContentStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEContentStore.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- J2EEContentStore.java	7 Jan 2002 00:44:44 -0000	1.3
  +++ J2EEContentStore.java	25 Feb 2002 00:16:52 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEContentStore.java,v 1.3 2002/01/07 00:44:44 dirkv Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/01/07 00:44:44 $
  + * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEContentStore.java,v 1.4 2002/02/25 00:16:52 msmith Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/25 00:16:52 $
    *
    * ====================================================================
    *
  @@ -97,9 +97,9 @@
    *
    * @author Ashok Kumar
    * @contact <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class J2EEContentStore extends AbstractService
  +public class J2EEContentStore extends J2EEStore
       implements ContentStore {
   
   
  @@ -115,269 +115,6 @@
       protected static final int REVISION_NUMBER = 2;
       protected static final int REVISION_CONTENT = 3;
   
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -
  -    /**
  -     * Datasource connection.
  -     */
  -    protected Connection connection;
  -    protected DataSource ds;
  -    protected String datasource;
  -
  -    /**
  -     * Driver class name.
  -     */
  -    protected String driver;
  -
  -
  -    /**
  -     * Connection URL.
  -     */
  -    protected String url;
  -
  -
  -    /**
  -     * User name.
  -     */
  -    protected String user;
  -
  -
  -    /**
  -     * Password.
  -     */
  -    protected String password;
  -
  -    /**
  -     * This store doesn't handle nested transactions, this variable keeps track
  -     * if the store is already enlisted to a transaction.
  -     */
  -    protected boolean alreadyEnlisted=false;
  -
  -    // -------------------------------------------------------- Service Methods
  -
  -    /**
  -     * Returns the sql statements to create the database objects.
  -     */
  -    protected String[] getDatabaseCreateStatements()
  -    {
  -        String[] statements = {
  -           "create table revisioncontent(uri varchar(65536), " +
  -           "xnumber varchar(20), content LONGVARBINARY)"};
  -
  -        return statements;
  -    }
  -
  -    /**
  -     * Read parameters.
  -     *
  -     * @param parameters Hashtable containing the parameters' name
  -     * and associated value
  -     */
  -    public synchronized void setParameters(Hashtable parameters)
  -        throws ServiceParameterErrorException,
  -        ServiceParameterMissingException {
  -        // Get the datsource lookup name
  -        datasource = (String) parameters.get("datasource");
  -
  -    }
  -
  -
  -    /**
  -     * Connects to Datasource and creates the basic table structure.
  -     *
  -     * @exception ServiceConnectionFailedException Connection to the
  -     * database failed
  -     */
  -    public synchronized void connect()
  -        throws ServiceConnectionFailedException {
  -
  -        getLogger().log("Connecting to datasource: " + datasource,LOG_CHANNEL,Logger.INFO);
  -        try {
  -		      connection = ds.getConnection();
  -        } catch (SQLException e) {
  -            getLogger().log("Connecting to datasource: " + datasource +" failed",LOG_CHANNEL,Logger.ERROR);
  -            getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceConnectionFailedException(this, e);
  -        }
  -
  -        // all updates must be done inside a transaction, no auto commits
  -        try {
  -            connection.setAutoCommit(false);
  -        } catch (SQLException e) {
  -        }
  -
  -        Statement statement = null;
  -        try {
  -            statement = connection.createStatement();
  -            String[] statements = getDatabaseCreateStatements();
  -            for (int i=0; i<statements.length ; i++ ) {
  -                statement.execute(statements[i]);
  -            }
  -            // Cloudscape needs a commit on DDL statements (create,...)
  -            connection.commit();
  -        } catch (SQLException e) {
  -            try { connection.rollback(); } catch (SQLException ex) { }
  -        } finally {
  -            closeStatement(statement);
  -        }
  -
  -        // we are just connected and are not enlisted
  -        alreadyEnlisted=false;
  -    }
  -
  -
  -    /**
  -     * Disconnects from content store.
  -     *
  -     * @exception ServiceDisconnectionFailedException
  -     */
  -    public synchronized void disconnect()
  -        throws ServiceDisconnectionFailedException {
  -        getLogger().log("Disconnecting from datasource: " + datasource,LOG_CHANNEL,Logger.INFO);
  -        try {
  -            if (connection != null)
  -                connection.close();
  -            connection = null;
  -        } catch (SQLException e) {
  -            getLogger().log("Disconnecting from datasource: " + datasource +"  failed",LOG_CHANNEL,Logger.ERROR);
  -            getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceDisconnectionFailedException(this, e);
  -        }
  -    }
  -
  -
  -    /**
  -     * Initializes content store.
  -     *
  -     * @exception ServiceInitializationFailedException Throws an exception
  -     * if the store has already been initialized before
  -     */
  -    public synchronized void initialize(NamespaceAccessToken token)
  -        throws ServiceInitializationFailedException {
  -        try {
  -
  -            // Loading and registering driver
  -            token.getLogger().log("Loading and registering datasource " + datasource ,LOG_CHANNEL,Logger.INFO);
  -			//	Initialize database
  -			Context initCtx = new InitialContext();
  -			Context envCtx = (Context) initCtx.lookup("java:comp/env");
  -			ds = (DataSource) envCtx.lookup(datasource);
  -		} catch (ClassCastException e) {
  -            token.getLogger().log("Loading and registering datasource " + datasource + " failed",LOG_CHANNEL,Logger.ERROR);
  -            token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceInitializationFailedException(this, e.getMessage());
  -		} catch (NamingException e) {
  -            token.getLogger().log("Loading and registering datasource " + datasource + " failed",LOG_CHANNEL,Logger.ERROR);
  -            token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceInitializationFailedException(this, e.getMessage());
  -        } catch (Exception e) {
  -            token.getLogger().log("Loading and registering datasource " + datasource+ " failed",LOG_CHANNEL,Logger.ERROR);
  -            token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceInitializationFailedException(this, e.getMessage());
  -        }
  -    }
  -
  -
  -    /**
  -     * Deletes content store.
  -     *
  -     * @exception ServiceResetFailedException
  -     */
  -    public void reset()
  -        throws ServiceResetFailedException {
  -        try {
  -            connectIfNeeded();
  -            Statement statement = connection.createStatement();
  -            String s = "drop table revisioncontent";
  -            statement.execute(s);
  -            statement.close();
  -            disconnect();
  -        } catch (SQLException e) {
  -            throw new ServiceResetFailedException(this, e.getMessage());
  -        } catch (ServiceAccessException e) {
  -            throw new ServiceResetFailedException(this, e.getMessage());
  -        } catch (ServiceConnectionFailedException e) {
  -            throw new ServiceResetFailedException(this, e.getMessage());
  -        } catch (ServiceDisconnectionFailedException e) {
  -            throw new ServiceResetFailedException(this, e.getMessage());
  -        }
  -    }
  -
  -
  -    /**
  -     * This function tells whether or not the service is connected.
  -     *
  -     * @return boolean true if we are connected
  -     * @exception ServiceAccessException Service access error
  -     */
  -    public boolean isConnected()
  -        throws ServiceAccessException {
  -        try {
  -            return ((connection != null) && (!connection.isClosed()));
  -        } catch (SQLException e) {
  -            throw new ServiceAccessException(this, e);
  -        }
  -    }
  -
  -
  -    // ----------------------------------------------------- XAResource Methods
  -
  -
  -    /**
  -     * Commit the global transaction specified by xid.
  -     */
  -    public void commit(Xid xid, boolean onePhase)
  -        throws XAException {
  -        super.commit(xid, onePhase);
  -        try {
  -//            getLogger().log("commit",LOG_CHANNEL,Logger.DEBUG);
  -            connection.commit();
  -        } catch (SQLException e) {
  -            throw new XAException(XAException.XA_RBCOMMFAIL);
  -        }
  -        alreadyEnlisted=false;
  -    }
  -
  -
  -    /**
  -     * Inform the resource manager to roll back work done on behalf of a
  -     * transaction branch.
  -     */
  -    public void rollback(Xid xid)
  -        throws XAException {
  -        super.rollback(xid);
  -        try {
  -//            getLogger().log("rollback",LOG_CHANNEL,Logger.DEBUG);
  -            connection.rollback();
  -        } catch (SQLException e) {
  -            throw new XAException(XAException.XA_HEURCOM);
  -        }
  -        alreadyEnlisted=false;
  -    }
  -
  -
  -    /**
  -     * Start work on behalf of a transaction branch specified in xid.
  -     */
  -    public void start(Xid xid, int flags)
  -        throws XAException {
  -        super.start(xid, flags);
  -        if (!alreadyEnlisted)
  -        {
  -            try {
  -//                getLogger().log("start",LOG_CHANNEL,Logger.DEBUG);
  -           // discard changes made outside a tranaction
  -                connection.rollback();
  -            } catch (SQLException e) {
  -                throw new XAException(XAException.XAER_RMERR);
  -            }
  -            alreadyEnlisted=true;
  -        }
  -    }
  -
  -
       // --------------------------------------------------- ContentStore Methods
   
   
  @@ -390,15 +127,18 @@
       public NodeRevisionContent retrieveRevisionContent
           (Uri uri, NodeRevisionDescriptor revisionDescriptor)
           throws ServiceAccessException, RevisionNotFoundException {
  +            
  +        Connection connection = getCurrentConnection();
   
           NodeRevisionContent result = null;
           String revisionUri = uri.toString();
           String revisionNumber =
               revisionDescriptor.getRevisionNumber().toString();
   
  +        PreparedStatement selectStatement=null;
           try {
   
  -            PreparedStatement selectStatement = connection.prepareStatement
  +            selectStatement = connection.prepareStatement
                   ("select * from revisioncontent where uri = ? and "
                    + "xnumber = ?");
               selectStatement.setString(1, revisionUri);
  @@ -415,6 +155,8 @@
   
               InputStream is = rs.getBinaryStream(REVISION_CONTENT);
               if (is == null) {
  +                rs.close();
  +                selectStatement.close();
                   throw new RevisionNotFoundException
                       (uri.toString(),
                        revisionDescriptor.getRevisionNumber());
  @@ -456,6 +198,8 @@
            NodeRevisionContent revisionContent)
           throws ServiceAccessException, RevisionAlreadyExistException {
   
  +        Connection connection = getCurrentConnection();
  +
           String revisionUri = uri.toString();
           String revisionNumber =
               revisionDescriptor.getRevisionNumber().toString();
  @@ -515,6 +259,8 @@
            NodeRevisionContent revisionContent)
           throws ServiceAccessException, RevisionNotFoundException {
   
  +        Connection connection = getCurrentConnection();
  +
           String revisionUri = uri.toString();
           String revisionNumber =
               revisionDescriptor.getRevisionNumber().toString();
  @@ -600,6 +346,8 @@
                                   NodeRevisionContent revisionContent)
           throws IOException, SQLException {
   
  +        Connection connection = getCurrentConnection();
  +
           PreparedStatement insertStatement = connection.prepareStatement
               ("insert into revisioncontent values(?, ?, ?)");
           insertStatement.setString(1, revisionUri);
  @@ -676,6 +424,8 @@
       protected void removeContent(String revisionUri, String revisionNumber)
           throws SQLException {
   
  +        Connection connection = getCurrentConnection();
  +
           PreparedStatement deleteStatement = connection.prepareStatement
               ("delete from revisioncontent where uri = ? and xnumber = ?");
           deleteStatement.setString(1, revisionUri);
  @@ -684,19 +434,5 @@
           deleteStatement.close();
   
       }
  -
  -
  -    /**
  -     * Close specified statement.
  -     */
  -    protected void closeStatement(Statement statement) {
  -        if (statement != null) {
  -            try {
  -                statement.close();
  -            } catch (SQLException e) {
  -            }
  -        }
  -    }
  -
   
   }
  
  
  
  1.5       +6 -441    jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore.java
  
  Index: J2EEDescriptorsStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- J2EEDescriptorsStore.java	22 Feb 2002 04:05:01 -0000	1.4
  +++ J2EEDescriptorsStore.java	25 Feb 2002 00:16:52 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore.java,v 1.4 2002/02/22 04:05:01 msmith Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/22 04:05:01 $
  + * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore.java,v 1.5 2002/02/25 00:16:52 msmith Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/25 00:16:52 $
    *
    * ====================================================================
    *
  @@ -89,27 +89,23 @@
   import javax.naming.NamingException;
   
   /**
  - * J2EE store implementation.
  + * J2EE descriptors store implementation.
    *
    * Alpha version (for development only)
    *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    * @author Ashok Kumar
    * @author <a href="mailto:msmith@apache.org">Michael Smith</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   
   public class J2EEDescriptorsStore
  -    extends AbstractXAService
  +    extends J2EEStore
       implements LockStore, NodeStore, RevisionDescriptorsStore, 
       RevisionDescriptorStore, SecurityStore {
   
       // -------------------------------------------------------------- Constants
       
  -    public static final int TX_IDLE = 0;
  -    public static final int TX_PREPARED = 1;
  -    public static final int TX_SUSPENDED = 1;
  -    
       // Column numbers
       
       // Structure descriptors
  @@ -176,365 +172,6 @@
       protected static final int PROPERTY_TYPE = 6;
       protected static final int PROPERTY_PROTECTED = 7;
   
  -    
  -    // ----------------------------------------------------- Instance Variables
  -    
  -    
  -    /**
  -     * Database connection source.
  -     */
  -    protected DataSource ds;
  -    protected String datasource;    
  -
  -    protected Hashtable connectionMap = new Hashtable();
  -
  -    /* A connection used when we aren't associated with a transaction correctly. */
  -    protected Connection globalConnection;
  -    
  -    // -------------------------------------------------------- Service Methods
  -    
  -    /**
  -     * Initializes the data source with a set of parameters.
  -     *
  -     * @param parameters Hashtable containing the parameters' name 
  -     * and associated value
  -     * @exception ServiceParameterErrorException Incorrect service parameter
  -     * @exception ServiceParameterMissingException Service parameter missing
  -     */
  -    public void setParameters(Hashtable parameters)
  -        throws ServiceParameterErrorException, 
  -        ServiceParameterMissingException {
  -        // Get the datsource lookup name
  -		datasource = (String) parameters.get("datasource");
  -    }
  -    
  -    
  -    /**
  -     * Connects to JDBC and creates the basic table structure.
  -     * 
  -     * @exception ServiceConnectionFailedException Connection to the 
  -     * database failed
  -     */
  -    public synchronized void connect()
  -        throws ServiceConnectionFailedException {
  -            getLogger().log("Trying connect to database", LOG_CHANNEL, 
  -                    Logger.INFO);
  -        try {
  -            globalConnection = ds.getConnection();
  -        } catch(SQLException e) {
  -            getLogger().log("Couldn't get global transaction.", LOG_CHANNEL,
  -                    Logger.ERROR);
  -        }
  -        getLogger().log("Done connecting to database. globalConnection is "+
  -                globalConnection, LOG_CHANNEL, Logger.INFO);
  -    }
  -
  -    /**
  -     * Returns connection status
  -     */
  -    public boolean isConnected() {
  -        try {
  -            return ds!=null && globalConnection != null && !globalConnection.isClosed();
  -        } catch(SQLException e) {
  -            return false;
  -        }
  -    }
  -    
  -    
  -    /**
  -     * Disconnects from data source.
  -     *
  -     * @exception ServiceDisconnectionFailedException Disconnection 
  -     * from database failed
  -     */
  -    public void disconnect()
  -        throws ServiceDisconnectionFailedException {
  -        // This doesn't need to do anything any more.
  -        try {
  -            globalConnection.close();
  -        } catch(SQLException e) {
  -            getLogger().log("Failed to close special global connection: "+
  -                    e.getMessage(), LOG_CHANNEL, Logger.ERROR);
  -        }
  -    }
  -
  -    /**
  -     * Initializes data source.
  -     * <p/>
  -     * Occurs in two steps :
  -     * <li>Datasource is looked up from the pool</li>
  -     * <li>Creation of the basic tables, if they didn't exist before</li>
  -     * 
  -     * @exception ServiceInitializationFailedException Throws an exception 
  -     * if the data source has already been initialized before
  -     */
  -    public synchronized void initialize(NamespaceAccessToken token)
  -        throws ServiceInitializationFailedException {
  -        try {
  -
  -            // Loading and registering driver
  -            token.getLogger().log("Loading and registering datasource " + datasource ,LOG_CHANNEL,Logger.INFO);
  -
  -			//	Initialize database
  -			Context initCtx = new InitialContext();
  -			Context envCtx = (Context) initCtx.lookup("java:comp/env");
  -			ds = (DataSource) envCtx.lookup(datasource);
  -		} catch (ClassCastException e) {
  -            token.getLogger().log("Loading and registering datasource " + datasource + " failed",LOG_CHANNEL,Logger.ERROR);
  -            token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceInitializationFailedException(this, e.getMessage());
  -		} catch (NamingException e) {
  -            token.getLogger().log("Loading and registering datasource " + datasource + " failed",LOG_CHANNEL,Logger.ERROR);
  -            token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceInitializationFailedException(this, e.getMessage());
  -        } catch (Exception e) {
  -            token.getLogger().log("Loading and registering datasource " + datasource+ " failed",LOG_CHANNEL,Logger.ERROR);
  -            token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
  -            throw new ServiceInitializationFailedException(this, e.getMessage());
  -        }
  -
  -        if(ds == null) {
  -            token.getLogger().log("Datasource is null, can't initialise store");
  -            throw new ServiceInitializationFailedException(this, "Null datasource from context");
  -        }
  -    }
  -    
  -    
  -    /**
  -     * Deletes data source. Should remove stored data if possible.
  -     *
  -     * @exception ServiceResetFailedException Reset failed
  -     */
  -    public synchronized void reset()
  -        throws ServiceResetFailedException {
  -    }
  -    
  -    
  -    // ----------------------------------------------------- XAResource Methods
  -    
  -    /**
  -     * Get the transaction timeout value for this XAResource.
  -     * Just returns 0, we don't have a way of doing transaction timeouts
  -     * with the connection.
  -     */
  -    public int getTransactionTimeout() throws XAException {
  -        return 0;
  -    }
  -
  -    /**
  -     * Set transaction timeout, not implemented (returns false).
  -     */
  -    public boolean setTransactionTimeout(int timeout) throws XAException {
  -        return false;
  -    }
  -
  -    public Xid[] recover(int flag) 
  -        throws XAException {
  -        
  -        getLogger().log("recover() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
  -        TransactionId id = (TransactionId)connectionMap.get(
  -                Thread.currentThread());
  -
  -        if(id != null && id.status == TX_PREPARED) {
  -            Xid[] xids = new Xid[1];
  -            xids[0] = id.xid;
  -            return xids;
  -        }
  -        else
  -            return new Xid[0];
  -    }
  -
  -    public int prepare(Xid xid) 
  -        throws XAException {
  -        
  -        getLogger().log("prepare() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
  -        TransactionId id = (TransactionId)connectionMap.get(
  -                Thread.currentThread());
  -
  -        if(id == null)
  -            throw new XAException(XAException.XAER_NOTA);
  -        if(xid == null)
  -            throw new XAException(XAException.XAER_INVAL);
  -        
  -        if(id.status != TX_IDLE && id.status != TX_SUSPENDED)
  -            throw new XAException(XAException.XAER_PROTO);
  -
  -        if(id.rollbackOnly)
  -            throw new XAException(XAException.XA_RBROLLBACK);
  -
  -        id.status = TX_PREPARED;
  -
  -        return XAResource.XA_OK;
  -    }
  -
  -    public boolean isSameRM(XAResource xares) throws XAException {
  -        if(xares == null)
  -            return false;
  -        else
  -            return this == xares;
  -    }
  -
  -    public void forget(Xid xid) throws XAException {
  -
  -        getLogger().log("forget() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
  -        TransactionId id = (TransactionId)connectionMap.get(
  -                Thread.currentThread());
  -
  -        if(id == null || id.xid == null)
  -            throw new XAException(XAException.XAER_NOTA);
  -
  -        if(xid == null)
  -            throw new XAException(XAException.XAER_INVAL);
  -
  -        try {
  -            id.connection.close();
  -        } catch(SQLException e) {
  -            getLogger().log("Couldn't close connection.", LOG_CHANNEL, Logger.ERROR);
  -        }
  -        getLogger().log("forget(): removing from map: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
  -        connectionMap.remove(Thread.currentThread()); 
  -    }
  -
  -    public void end(Xid xid, int flags) throws XAException {
  -
  -        getLogger().log("end() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
  -        TransactionId id = (TransactionId)connectionMap.get(Thread.currentThread());
  -        if(id == null || id.xid == null)
  -            throw new XAException(XAException.XAER_NOTA);
  -        if(xid == null)
  -            throw new XAException(XAException.XAER_INVAL);
  -
  -        if(flags == XAResource.TMSUSPEND)
  -            id.status = TX_SUSPENDED;
  -
  -        if(flags == XAResource.TMFAIL) 
  -            id.rollbackOnly = true;
  -
  -    }
  -
  -
  -    
  -    /**
  -     * Commit the global transaction specified by xid.
  -     */
  -    public void commit(Xid xid, boolean onePhase)
  -        throws XAException {
  -
  -        getLogger().log("commit() for thread "+Thread.currentThread()+", removing from map",
  -                LOG_CHANNEL, Logger.INFO);
  -
  -        TransactionId id = (TransactionId)connectionMap.remove(
  -                Thread.currentThread());
  -        if(id == null) {
  -            getLogger().log("Error committing: no transaction associated with current thread", LOG_CHANNEL, Logger.ERROR);
  -            throw new XAException(XAException.XAER_NOTA);
  -        }
  -        if(xid == null)
  -            throw new XAException(XAException.XAER_INVAL);
  -
  -        if(!onePhase && id.status != TX_PREPARED)
  -            throw new XAException(XAException.XAER_PROTO);
  -        if(onePhase && (!(id.status == TX_IDLE || id.status == TX_SUSPENDED)))
  -            throw new XAException(XAException.XAER_PROTO);
  -
  -        Connection conn = id.connection;
  -
  -        if(conn == null) {
  -            getLogger().log("commit(): No connection in connectionMap for id \""+id+"\"", LOG_CHANNEL, Logger.ERROR);
  -            throw new XAException(XAException.XAER_NOTA);
  -        }
  -
  -        try {
  -            if(id.rollbackOnly)
  -                conn.rollback();
  -            else
  -                conn.commit();
  -        } catch(SQLException e) {
  -            throw new XAException(XAException.XA_RBCOMMFAIL);
  -        } finally {
  -            try {
  -                conn.close(); /* We must always return connections to the pool,
  -                                 or we'd eventually run out. */
  -            } catch(SQLException e) {
  -                getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Inform the resource manager to roll back work done on behalf of a
  -     * transaction branch.
  -     */
  -    public void rollback(Xid xid)
  -        throws XAException {
  -
  -        getLogger().log("rollback() for thread "+Thread.currentThread()+", removing from map",
  -                LOG_CHANNEL, Logger.INFO);
  -
  -        TransactionId id = (TransactionId)connectionMap.remove(
  -                Thread.currentThread());
  -        if(id == null) {
  -            getLogger().log("No transaction associated with current thread, can't rollback", LOG_CHANNEL, Logger.ERROR);
  -            throw new XAException(XAException.XAER_NOTA);
  -        }
  -
  -        Connection conn = id.connection;
  -        if(conn == null) {
  -            getLogger().log("rollback(): No connection in connectionMap for id \""+id+"\"", LOG_CHANNEL, Logger.ERROR);
  -            throw new XAException(XAException.XAER_NOTA);
  -        }
  -        try {
  -            conn.rollback();
  -        } catch (SQLException e) {
  -            throw new XAException(XAException.XA_HEURCOM);
  -        } finally {
  -            try {
  -                conn.close(); /* We must always return connections to the pool,
  -                                 or we'd eventually run out. */
  -            } catch(SQLException e) {
  -                getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
  -            }
  -        }
  -    }
  -    
  -    
  -   /**
  -    * Start work on behalf of a transaction branch specified in xid.
  -    */
  -   public void start(Xid xid, int flags)
  -       throws XAException {
  -           getLogger().log("start(): beginning transaction with xid "+xid, LOG_CHANNEL, Logger.INFO);
  -
  -       TransactionId id = (TransactionId)connectionMap.get(Thread.currentThread());
  -
  -       switch(flags) {
  -           case XAResource.TMNOFLAGS:
  -               if(id != null)
  -                   throw new XAException(XAException.XAER_INVAL);
  -               id = new TransactionId(xid, TX_IDLE);
  -
  -               getLogger().log("start(): adding to map for "+Thread.currentThread(),
  -                   LOG_CHANNEL, Logger.INFO);
  -
  -               connectionMap.put(Thread.currentThread(), id);
  -               break;
  -           case XAResource.TMJOIN:
  -               getLogger().log("TMJOIN for transaction in thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
  -               if(id == null)
  -                   throw new XAException(XAException.XAER_NOTA);
  -               break;
  -           case XAResource.TMRESUME:
  -               getLogger().log("TMRESUME for transaction in thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
  -               if(id == null)
  -                   throw new XAException(XAException.XAER_NOTA);
  -               if(id.status != TX_SUSPENDED)
  -                   throw new XAException(XAException.XAER_INVAL);
  -               id.status = TX_IDLE;
  -               break;
  -       }
  -
  -   }    
  -
       // ----------------------------------------------- DescriptorsStore Methods
       
       
  @@ -1722,76 +1359,4 @@
       
       
       // ------------------------------------------------------ Protected Methods
  -    
  -    
  -    /**
  -     * Close specified statement.
  -     */
  -    protected void closeStatement(Statement statement) {
  -        if (statement != null) {
  -            try {
  -                statement.close();
  -            } catch (SQLException e) {
  -                getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
  -            }
  -        }
  -    }
  -
  -    /** 
  -     * Get the Connection object associated with the current transaction.
  -     */
  -
  -    protected Connection getCurrentConnection() {
  -
  -//        getLogger().log("Getting current connection for thread "+
  -//                Thread.currentThread(), LOG_CHANNEL, Logger.INFO);
  -        TransactionId id = (TransactionId)connectionMap.get(Thread.currentThread());
  -        if(id == null) {
  -            getLogger().log("No id for current thread - called outside transaction?", LOG_CHANNEL, Logger.INFO);
  -            return globalConnection;
  -        }
  -
  -        Connection conn = id.connection;
  -
  -        if(conn == null) {
  -            getLogger().log("No connection for current id - shouldn't be possible", LOG_CHANNEL, Logger.ERROR);
  -            return globalConnection;
  -        }
  -
  -        getLogger().log("Returning current valid connection from map", LOG_CHANNEL, Logger.INFO);
  -        return conn;
  -    }
  -
  -    private class TransactionId 
  -    {
  -        public Xid xid;
  -        public int status;
  -        public boolean rollbackOnly;
  -        Connection connection;
  -
  -        public TransactionId(Xid xid, int status) {
  -            this.xid = xid;
  -            this.status = status;
  -            rollbackOnly = false;
  -
  -            /* Now, fetch a connection from the DataSource */
  -            try {
  -                connection = ds.getConnection();
  -                if(connection == null) {
  -                    System.out.println("CONNDEBUG: Got null connection from datasource");
  -                    connection = globalConnection;
  -                    return;
  -                }
  -
  -                connection.setAutoCommit(false);
  -                System.out.println("CONNDEBUG: Got connection successfully");
  -            } catch(SQLException e) {
  -                System.out.println("CONNDEBUG: Couldn't get connection: "+e.getMessage());
  -                connection = globalConnection;
  -                e.printStackTrace();
  -            }
  -        }
  -
  -    }
  -    
   }
  
  
  
  1.1                  jakarta-slide/src/stores/slidestore/j2ee/J2EEStore.java
  
  Index: J2EEStore.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEStore.java,v 1.1 2002/02/25 00:16:52 msmith Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/25 00:16:52 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package slidestore.j2ee;
  
  import java.lang.reflect.Constructor;
  import java.util.Hashtable;
  import java.util.Enumeration;
  import java.util.Vector;
  import java.util.Date;
  import java.util.Arrays;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.sql.*;
  import javax.transaction.xa.XAException;
  import javax.transaction.xa.XAResource;
  import javax.transaction.xa.Xid;
  import org.apache.slide.common.*;
  import org.apache.slide.util.logger.Logger;
  //For the Datasource implementation
  import javax.sql.DataSource;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  /**
   * J2EE store implementation - implements the shared parts of
   * the two (content, descriptors) J2EE stores.
   *
   * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
   * @author Ashok Kumar
   * @author <a href="mailto:msmith@apache.org">Michael Smith</a>
   * @version $Revision: 1.1 $
   */
  
  public abstract class J2EEStore
      extends AbstractXAService {
  
      // -------------------------------------------------------------- Constants
      
      public static final int TX_IDLE = 0;
      public static final int TX_PREPARED = 1;
      public static final int TX_SUSPENDED = 1;
      
      // ----------------------------------------------------- Instance Variables
      
      /**
       * Database connection source.
       */
      protected DataSource ds;
      protected String datasource;    
  
      protected Hashtable connectionMap = new Hashtable();
  
      /* A connection used when we aren't associated with a transaction correctly. */
      protected Connection globalConnection;
      
      // -------------------------------------------------------- Service Methods
      
      /**
       * Initializes the data source with a set of parameters.
       *
       * @param parameters Hashtable containing the parameters' name 
       * and associated value
       * @exception ServiceParameterErrorException Incorrect service parameter
       * @exception ServiceParameterMissingException Service parameter missing
       */
      public void setParameters(Hashtable parameters)
          throws ServiceParameterErrorException, 
          ServiceParameterMissingException {
          // Get the datsource lookup name
  		datasource = (String) parameters.get("datasource");
      }
      
      
      /**
       * Connects to JDBC and creates the basic table structure.
       * 
       * @exception ServiceConnectionFailedException Connection to the 
       * database failed
       */
      public synchronized void connect()
          throws ServiceConnectionFailedException {
              getLogger().log("Trying connect to database", LOG_CHANNEL, 
                      Logger.INFO);
          try {
              globalConnection = ds.getConnection();
          } catch(SQLException e) {
              getLogger().log("Couldn't get global transaction.", LOG_CHANNEL,
                      Logger.ERROR);
          }
          getLogger().log("Done connecting to database. globalConnection is "+
                  globalConnection, LOG_CHANNEL, Logger.INFO);
      }
  
      /**
       * Returns connection status
       */
      public boolean isConnected() {
          try {
              return ds!=null && globalConnection != null && !globalConnection.isClosed();
          } catch(SQLException e) {
              return false;
          }
      }
      
      
      /**
       * Disconnects from data source.
       *
       * @exception ServiceDisconnectionFailedException Disconnection 
       * from database failed
       */
      public void disconnect()
          throws ServiceDisconnectionFailedException {
          // This doesn't need to do anything any more.
          try {
              globalConnection.close();
          } catch(SQLException e) {
              getLogger().log("Failed to close special global connection: "+
                      e.getMessage(), LOG_CHANNEL, Logger.ERROR);
          }
      }
  
      /**
       * Initializes data source.
       * <p/>
       * Occurs in two steps :
       * <li>Datasource is looked up from the pool</li>
       * <li>Creation of the basic tables, if they didn't exist before</li>
       * 
       * @exception ServiceInitializationFailedException Throws an exception 
       * if the data source has already been initialized before
       */
      public synchronized void initialize(NamespaceAccessToken token)
          throws ServiceInitializationFailedException {
          try {
  
              // Loading and registering driver
              token.getLogger().log("Loading and registering datasource " + datasource ,LOG_CHANNEL,Logger.INFO);
  
  			//	Initialize database
  			Context initCtx = new InitialContext();
  			Context envCtx = (Context) initCtx.lookup("java:comp/env");
  			ds = (DataSource) envCtx.lookup(datasource);
  		} catch (ClassCastException e) {
              token.getLogger().log("Loading and registering datasource " + datasource + " failed",LOG_CHANNEL,Logger.ERROR);
              token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
              throw new ServiceInitializationFailedException(this, e.getMessage());
  		} catch (NamingException e) {
              token.getLogger().log("Loading and registering datasource " + datasource + " failed",LOG_CHANNEL,Logger.ERROR);
              token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
              throw new ServiceInitializationFailedException(this, e.getMessage());
          } catch (Exception e) {
              token.getLogger().log("Loading and registering datasource " + datasource+ " failed",LOG_CHANNEL,Logger.ERROR);
              token.getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR);
              throw new ServiceInitializationFailedException(this, e.getMessage());
          }
  
          if(ds == null) {
              token.getLogger().log("Datasource is null, can't initialise store");
              throw new ServiceInitializationFailedException(this, "Null datasource from context");
          }
      }
      
      
      /**
       * Deletes data source. Should remove stored data if possible.
       *
       * @exception ServiceResetFailedException Reset failed
       */
      public synchronized void reset()
          throws ServiceResetFailedException {
      }
      
      
      // ----------------------------------------------------- XAResource Methods
      
      /**
       * Get the transaction timeout value for this XAResource.
       * Just returns 0, we don't have a way of doing transaction timeouts
       * with the connection.
       */
      public int getTransactionTimeout() throws XAException {
          return 0;
      }
  
      /**
       * Set transaction timeout, not implemented (returns false).
       */
      public boolean setTransactionTimeout(int timeout) throws XAException {
          return false;
      }
  
      public Xid[] recover(int flag) 
          throws XAException {
          
          getLogger().log("recover() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
          TransactionId id = (TransactionId)connectionMap.get(
                  Thread.currentThread());
  
          if(id != null && id.status == TX_PREPARED) {
              Xid[] xids = new Xid[1];
              xids[0] = id.xid;
              return xids;
          }
          else
              return new Xid[0];
      }
  
      public int prepare(Xid xid) 
          throws XAException {
          
          getLogger().log("prepare() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
          TransactionId id = (TransactionId)connectionMap.get(
                  Thread.currentThread());
  
          if(id == null)
              throw new XAException(XAException.XAER_NOTA);
          if(xid == null)
              throw new XAException(XAException.XAER_INVAL);
          
          if(id.status != TX_IDLE && id.status != TX_SUSPENDED)
              throw new XAException(XAException.XAER_PROTO);
  
          if(id.rollbackOnly)
              throw new XAException(XAException.XA_RBROLLBACK);
  
          id.status = TX_PREPARED;
  
          return XAResource.XA_OK;
      }
  
      public boolean isSameRM(XAResource xares) throws XAException {
          if(xares == null)
              return false;
          else
              return this == xares;
      }
  
      public void forget(Xid xid) throws XAException {
  
          getLogger().log("forget() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
          TransactionId id = (TransactionId)connectionMap.get(
                  Thread.currentThread());
  
          if(id == null || id.xid == null)
              throw new XAException(XAException.XAER_NOTA);
  
          if(xid == null)
              throw new XAException(XAException.XAER_INVAL);
  
          try {
              id.connection.close();
          } catch(SQLException e) {
              getLogger().log("Couldn't close connection.", LOG_CHANNEL, Logger.ERROR);
          }
          getLogger().log("forget(): removing from map: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
          connectionMap.remove(Thread.currentThread()); 
      }
  
      public void end(Xid xid, int flags) throws XAException {
  
          getLogger().log("end() for thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.INFO);    
          TransactionId id = (TransactionId)connectionMap.get(Thread.currentThread());
          if(id == null || id.xid == null)
              throw new XAException(XAException.XAER_NOTA);
          if(xid == null)
              throw new XAException(XAException.XAER_INVAL);
  
          if(flags == XAResource.TMSUSPEND)
              id.status = TX_SUSPENDED;
  
          if(flags == XAResource.TMFAIL) 
              id.rollbackOnly = true;
  
      }
  
  
      
      /**
       * Commit the global transaction specified by xid.
       */
      public void commit(Xid xid, boolean onePhase)
          throws XAException {
  
          getLogger().log("commit() for thread "+Thread.currentThread()+", removing from map",
                  LOG_CHANNEL, Logger.INFO);
  
          TransactionId id = (TransactionId)connectionMap.remove(
                  Thread.currentThread());
          if(id == null) {
              getLogger().log("Error committing: no transaction associated with current thread", LOG_CHANNEL, Logger.ERROR);
              throw new XAException(XAException.XAER_NOTA);
          }
          if(xid == null)
              throw new XAException(XAException.XAER_INVAL);
  
          if(!onePhase && id.status != TX_PREPARED)
              throw new XAException(XAException.XAER_PROTO);
          if(onePhase && (!(id.status == TX_IDLE || id.status == TX_SUSPENDED)))
              throw new XAException(XAException.XAER_PROTO);
  
          Connection conn = id.connection;
  
          if(conn == null) {
              getLogger().log("commit(): No connection in connectionMap for id \""+id+"\"", LOG_CHANNEL, Logger.ERROR);
              throw new XAException(XAException.XAER_NOTA);
          }
  
          try {
              if(id.rollbackOnly)
                  conn.rollback();
              else
                  conn.commit();
          } catch(SQLException e) {
              throw new XAException(XAException.XA_RBCOMMFAIL);
          } finally {
              try {
                  conn.close(); /* We must always return connections to the pool,
                                   or we'd eventually run out. */
              } catch(SQLException e) {
                  getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
              }
          }
      }
  
      /**
       * Inform the resource manager to roll back work done on behalf of a
       * transaction branch.
       */
      public void rollback(Xid xid)
          throws XAException {
  
          getLogger().log("rollback() for thread "+Thread.currentThread()+", removing from map",
                  LOG_CHANNEL, Logger.INFO);
  
          TransactionId id = (TransactionId)connectionMap.remove(
                  Thread.currentThread());
          if(id == null) {
              getLogger().log("No transaction associated with current thread, can't rollback", LOG_CHANNEL, Logger.ERROR);
              throw new XAException(XAException.XAER_NOTA);
          }
  
          Connection conn = id.connection;
          if(conn == null) {
              getLogger().log("rollback(): No connection in connectionMap for id \""+id+"\"", LOG_CHANNEL, Logger.ERROR);
              throw new XAException(XAException.XAER_NOTA);
          }
          try {
              conn.rollback();
          } catch (SQLException e) {
              throw new XAException(XAException.XA_HEURCOM);
          } finally {
              try {
                  conn.close(); /* We must always return connections to the pool,
                                   or we'd eventually run out. */
              } catch(SQLException e) {
                  getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
              }
          }
      }
      
      
     /**
      * Start work on behalf of a transaction branch specified in xid.
      */
     public void start(Xid xid, int flags)
         throws XAException {
             getLogger().log("start(): beginning transaction with xid "+xid, LOG_CHANNEL, Logger.INFO);
  
         TransactionId id = (TransactionId)connectionMap.get(Thread.currentThread());
  
         switch(flags) {
             case XAResource.TMNOFLAGS:
                 if(id != null)
                     throw new XAException(XAException.XAER_INVAL);
                 id = new TransactionId(xid, TX_IDLE);
  
                 getLogger().log("start(): adding to map for "+Thread.currentThread(),
                     LOG_CHANNEL, Logger.INFO);
  
                 connectionMap.put(Thread.currentThread(), id);
                 break;
             case XAResource.TMJOIN:
                 getLogger().log("TMJOIN for transaction in thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
                 if(id == null)
                     throw new XAException(XAException.XAER_NOTA);
                 break;
             case XAResource.TMRESUME:
                 getLogger().log("TMRESUME for transaction in thread: "+Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
                 if(id == null)
                     throw new XAException(XAException.XAER_NOTA);
                 if(id.status != TX_SUSPENDED)
                     throw new XAException(XAException.XAER_INVAL);
                 id.status = TX_IDLE;
                 break;
         }
  
     }    
  
      // ------------------------------------------------------ Protected Methods
      
      
      /**
       * Close specified statement.
       */
      protected void closeStatement(Statement statement) {
          if (statement != null) {
              try {
                  statement.close();
              } catch (SQLException e) {
                  getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
              }
          }
      }
  
      /** 
       * Get the Connection object associated with the current transaction.
       */
  
      protected Connection getCurrentConnection() {
  
  //        getLogger().log("Getting current connection for thread "+
  //                Thread.currentThread(), LOG_CHANNEL, Logger.INFO);
          TransactionId id = (TransactionId)connectionMap.get(Thread.currentThread());
          if(id == null) {
              getLogger().log("No id for current thread - called outside transaction?", LOG_CHANNEL, Logger.INFO);
              return globalConnection;
          }
  
          Connection conn = id.connection;
  
          if(conn == null) {
              getLogger().log("No connection for current id - shouldn't be possible", LOG_CHANNEL, Logger.ERROR);
              return globalConnection;
          }
  
          getLogger().log("Returning current valid connection from map", LOG_CHANNEL, Logger.INFO);
          return conn;
      }
  
      private class TransactionId 
      {
          public Xid xid;
          public int status;
          public boolean rollbackOnly;
          Connection connection;
  
          public TransactionId(Xid xid, int status) {
              this.xid = xid;
              this.status = status;
              rollbackOnly = false;
  
              /* Now, fetch a connection from the DataSource */
              try {
                  connection = ds.getConnection();
                  if(connection == null) {
                      System.out.println("CONNDEBUG: Got null connection from datasource");
                      connection = globalConnection;
                      return;
                  }
  
                  connection.setAutoCommit(false);
                  System.out.println("CONNDEBUG: Got connection successfully");
              } catch(SQLException e) {
                  System.out.println("CONNDEBUG: Couldn't get connection: "+e.getMessage());
                  connection = globalConnection;
                  e.printStackTrace();
              }
          }
  
      }
      
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>