001: /*
002: * XAPool: Open Source XA JDBC Pool
003: * Copyright (C) 2003 Objectweb.org
004: * Initial Developer: Lutris Technologies Inc.
005: * Contact: xapool-public@lists.debian-sf.objectweb.org
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: */
022: package org.enhydra.jdbc.standard;
023:
024: import java.sql.SQLException;
025:
026: public class StandardXAPreparedStatement extends
027: StandardPreparedStatement {
028:
029: private StandardXAConnectionHandle con;
030: // the StandardXAConnectionHandle that created this object
031: public String sql;
032: public int resultSetType;
033: public int resultSetConcurrency;
034: public int resultSetHoldability;
035: public int autoGeneratedKeys;
036:
037: StandardXAPreparedStatement(StandardXAConnectionHandle con_,
038: String sql_, int resultSetType_, int resultSetConcurrency_,
039: int resultSetHoldability_) throws SQLException {
040: this .con = con_;
041: this .sql = sql_;
042: this .key = sql_ + resultSetType_ + resultSetConcurrency_
043: + resultSetHoldability_;
044: this .resultSetType = resultSetType_;
045: this .resultSetConcurrency = resultSetConcurrency_;
046: this .resultSetHoldability = resultSetHoldability_;
047:
048: log = con_.log;
049: log
050: .debug("StandardXAPreparedStatement: Create an XAPreparedStatement with sql='"
051: + sql + "'");
052:
053: key = sql + resultSetType + resultSetConcurrency
054: + resultSetHoldability
055: + ((con.tx != null) ? true : false);
056: ps = con.checkPreparedCache(sql, resultSetType,
057: resultSetConcurrency, resultSetHoldability, key);
058: // from cney
059: // ps = con.checkPreparedCache(sql, resultSetType, resultSetConcurrency,key);
060: }
061:
062: StandardXAPreparedStatement(StandardXAConnectionHandle con_,
063: String sql_, int autoGeneratedKeys_) throws SQLException {
064: this .con = con_;
065: this .sql = sql_;
066: this .key = sql_ + autoGeneratedKeys_;
067: this .autoGeneratedKeys = autoGeneratedKeys_;
068:
069: log = con_.log;
070: log
071: .debug("StandardXAPreparedStatement: Create an XAPreparedStatement with sql='"
072: + sql + "'");
073:
074: key = sql + autoGeneratedKeys
075: + ((con.tx != null) ? true : false);
076: ps = con.checkPreparedCache(sql, autoGeneratedKeys, key);
077: // from cney
078: // ps = con.checkPreparedCache(sql, resultSetType, resultSetConcurrency,key);
079: }
080:
081: /**
082: * Close this statement.
083: */
084: public synchronized void close() throws SQLException {
085: log
086: .debug("StandardXAPreparedStatement:close the XA prepared statement");
087: // Note no check for already closed - some servers make mistakes
088: closed = true;
089: if (con.preparedStmtCacheSize == 0) {
090: log
091: .debug("StandardXAPreparedStatement:close preparedStmtCacheSize == 0");
092: if (ps != null) {
093: ps.close(); // no cache, so we can close
094: }
095: } else {
096: log
097: .debug("StandardXAPreparedStatement:close preparedStmtCacheSize="
098: + "'" + con.preparedStmtCacheSize + "'");
099: con.returnToCache(key);
100: // return the underlying statement to the cache
101: }
102: }
103:
104: /**
105: * Exception management : catch or throw the exception
106: */
107: public void catchInvoke(SQLException sqlException)
108: throws SQLException {
109: //ConnectionEvent event = new ConnectionEvent (con.pooledCon);
110: //con.pooledCon.connectionErrorOccurred(event);
111: throw (sqlException);
112: }
113:
114: }
|