KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jdbc > standard > StandardXAPreparedStatement


1 /*
2  * XAPool: Open Source XA JDBC Pool
3  * Copyright (C) 2003 Objectweb.org
4  * Initial Developer: Lutris Technologies Inc.
5  * Contact: xapool-public@lists.debian-sf.objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  */

22 package org.enhydra.jdbc.standard;
23
24 import java.sql.SQLException JavaDoc;
25
26 public class StandardXAPreparedStatement extends StandardPreparedStatement {
27
28     private StandardXAConnectionHandle con;
29     // the StandardXAConnectionHandle that created this object
30
public String JavaDoc sql;
31     public int resultSetType;
32     public int resultSetConcurrency;
33         public int resultSetHoldability;
34         public int autoGeneratedKeys;
35
36     StandardXAPreparedStatement(
37         StandardXAConnectionHandle con_,
38         String JavaDoc sql_,
39         int resultSetType_,
40         int resultSetConcurrency_,
41         int resultSetHoldability_)
42         throws SQLException JavaDoc {
43         this.con = con_;
44         this.sql = sql_;
45         this.key = sql_ + resultSetType_ + resultSetConcurrency_ + resultSetHoldability_;
46         this.resultSetType = resultSetType_;
47         this.resultSetConcurrency = resultSetConcurrency_;
48         this.resultSetHoldability = resultSetHoldability_;
49
50         log = con_.log;
51         log.debug(
52             "StandardXAPreparedStatement: Create an XAPreparedStatement with sql='"
53                 + sql
54                 + "'");
55
56         key =
57             sql
58                 + resultSetType
59                 + resultSetConcurrency
60                         + resultSetHoldability
61                 + ((con.tx != null) ? true : false);
62         ps =
63             con.checkPreparedCache(
64                 sql,
65                 resultSetType,
66                 resultSetConcurrency,
67                                 resultSetHoldability,
68                 key);
69         // from cney
70
// ps = con.checkPreparedCache(sql, resultSetType, resultSetConcurrency,key);
71
}
72
73     StandardXAPreparedStatement(
74         StandardXAConnectionHandle con_,
75         String JavaDoc sql_,
76         int autoGeneratedKeys_)
77         throws SQLException JavaDoc {
78         this.con = con_;
79         this.sql = sql_;
80         this.key = sql_ + autoGeneratedKeys_;
81         this.autoGeneratedKeys= autoGeneratedKeys_;
82
83         log = con_.log;
84         log.debug(
85             "StandardXAPreparedStatement: Create an XAPreparedStatement with sql='"
86                 + sql
87                 + "'");
88
89         key =
90             sql
91                 + autoGeneratedKeys
92                 + ((con.tx != null) ? true : false);
93         ps =
94             con.checkPreparedCache(
95                 sql,
96                 autoGeneratedKeys,
97                 key);
98         // from cney
99
// ps = con.checkPreparedCache(sql, resultSetType, resultSetConcurrency,key);
100
}
101
102
103     /**
104      * Close this statement.
105      */

106     public synchronized void close() throws SQLException JavaDoc {
107         log.debug(
108             "StandardXAPreparedStatement:close the XA prepared statement");
109         // Note no check for already closed - some servers make mistakes
110
closed = true;
111         if (con.preparedStmtCacheSize == 0) {
112             log.debug(
113                 "StandardXAPreparedStatement:close preparedStmtCacheSize == 0");
114             if (ps != null) {
115                 ps.close(); // no cache, so we can close
116
}
117         } else {
118             log.debug(
119                 "StandardXAPreparedStatement:close preparedStmtCacheSize="
120                     + "'"
121                     + con.preparedStmtCacheSize
122                     + "'");
123             con.returnToCache(key);
124             // return the underlying statement to the cache
125
}
126     }
127
128
129     /**
130      * Exception management : catch or throw the exception
131      */

132     public void catchInvoke(SQLException JavaDoc sqlException) throws SQLException JavaDoc {
133         //ConnectionEvent event = new ConnectionEvent (con.pooledCon);
134
//con.pooledCon.connectionErrorOccurred(event);
135
throw (sqlException);
136     }
137
138 }
139
Popular Tags