/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * Initial developer(s): ____________________________________.
 * Contributor(s): ______________________________________.
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.dbm;

import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import oracle.jdbc.xa.client.OracleXAConnection;

/**
 * To compile this class, you must have the classes12.zip file
 * from Oracle (driver JDBC 2.0 with Oracle 8.1.6 version), 
 * and add the current file to the build mechanism (Makefile)
 */
public class JonasOracleXAConnection extends OracleXAConnection {
    
    public TransactionManager 	transactionManager;
    public Transaction		tx;

    JonasOracleXAConnection() throws javax.transaction.xa.XAException {
	super();
    } // constructor

    public void setTransactionManager(TransactionManager tm) {
	this.transactionManager = tm;
    } // method setTransactionManager
    
    synchronized public PreparedStatement prepareStatement(String sql) throws SQLException {
	return new JonasOracleXAPreparedStatement (this ,sql, 0, 0);
    } // method PreparedStatement

    public PreparedStatement prepareStatement(String sql,int resultSetType,int resultSetConcurrency) throws SQLException {
	return new JonasOracleXAPreparedStatement (this, sql, resultSetType, resultSetConcurrency);
    } // prepareStatement
   
    public Statement createStatement() {
	return new JonasOracleXAStatement(this);
    } // method createStatement
    
    synchronized public void setAutoCommit(boolean autoCommit) throws SQLException {
	m_logicalHandle.setAutoCommit(autoCommit);	// delegation
    } // method setAutoCommit

    synchronized public PreparedStatement _prepareStatement(String sql) throws SQLException {
	return m_logicalHandle.prepareStatement(sql);
    } // method PreparedStatement
    
    public PreparedStatement _prepareStatement(String sql,int resultSetType,int resultSetConcurrency) throws SQLException {
	return m_logicalHandle.prepareStatement(sql,resultSetType,resultSetConcurrency);
    } // prepareStatement

} // class JonasOracleXAConnection
