KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > pm > lib > DSConnectionFilter


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2005 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S. Chassande-Barrioz
25  *
26  */

27 package org.objectweb.speedo.pm.lib;
28
29 import java.sql.CallableStatement JavaDoc;
30 import java.sql.Connection JavaDoc;
31 import java.sql.DatabaseMetaData JavaDoc;
32 import java.sql.PreparedStatement JavaDoc;
33 import java.sql.SQLException JavaDoc;
34 import java.sql.SQLWarning JavaDoc;
35 import java.sql.Savepoint JavaDoc;
36 import java.sql.Statement JavaDoc;
37 import java.util.Map JavaDoc;
38
39 import javax.jdo.JDOUserException;
40
41 /**
42  * This class implements the java.sql.Connection and delegates call to an inner
43  * connection. But some calls are forbidden by the JDO 2 specification (12.16).
44  *
45  * @author S.Chassande-Barrioz
46  */

47 public class DSConnectionFilter implements Connection JavaDoc {
48     
49     Connection JavaDoc inner;
50     
51     /**
52      * indicates if the inner connection must be closed or simply forgotten.
53      */

54     boolean reallyClose;
55     
56     /**
57      * @param inner
58      * @param reallyClose
59      */

60     public DSConnectionFilter(Object JavaDoc inner, boolean reallyClose) {
61         super();
62         this.inner = (Connection JavaDoc) inner;
63         this.reallyClose = reallyClose;
64     }
65     public void clearWarnings() throws SQLException JavaDoc {
66         throw new JDOUserException("Action forbidden on JDO connection");
67     }
68     public void close() throws SQLException JavaDoc {
69         if (reallyClose) {
70             inner.close();
71         }
72         inner = null;
73     }
74     public void commit() throws SQLException JavaDoc {
75         throw new JDOUserException("Action forbidden on JDO connection");
76     }
77     public Statement JavaDoc createStatement() throws SQLException JavaDoc {
78         return inner.createStatement();
79     }
80     public Statement JavaDoc createStatement(int resultSetType,
81             int resultSetConcurrency, int resultSetHoldability)
82             throws SQLException JavaDoc {
83         return inner.createStatement(
84                 resultSetType,resultSetConcurrency, resultSetHoldability);
85     }
86     public Statement JavaDoc createStatement(int resultSetType, int resultSetConcurrency)
87             throws SQLException JavaDoc {
88         return inner.createStatement(resultSetType, resultSetConcurrency);
89     }
90     public boolean getAutoCommit() throws SQLException JavaDoc {
91         return inner.getAutoCommit();
92     }
93     public String JavaDoc getCatalog() throws SQLException JavaDoc {
94         return inner.getCatalog();
95     }
96     public int getHoldability() throws SQLException JavaDoc {
97         return inner.getHoldability();
98     }
99     public DatabaseMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
100         throw new JDOUserException("Action forbidden on JDO connection");
101     }
102     public int getTransactionIsolation() throws SQLException JavaDoc {
103         return inner.getTransactionIsolation();
104     }
105     public Map JavaDoc getTypeMap() throws SQLException JavaDoc {
106         return inner.getTypeMap();
107     }
108     public SQLWarning JavaDoc getWarnings() throws SQLException JavaDoc {
109         return inner.getWarnings();
110     }
111     public boolean isClosed() throws SQLException JavaDoc {
112         return inner.isClosed();
113     }
114     public boolean isReadOnly() throws SQLException JavaDoc {
115         return inner.isReadOnly();
116     }
117     public String JavaDoc nativeSQL(String JavaDoc sql) throws SQLException JavaDoc {
118         return inner.nativeSQL(sql);
119     }
120     public CallableStatement JavaDoc prepareCall(String JavaDoc sql, int resultSetType,
121             int resultSetConcurrency, int resultSetHoldability)
122             throws SQLException JavaDoc {
123         return inner.prepareCall(sql,
124                 resultSetType, resultSetConcurrency, resultSetHoldability);
125     }
126     public CallableStatement JavaDoc prepareCall(String JavaDoc sql, int resultSetType,
127             int resultSetConcurrency) throws SQLException JavaDoc {
128         return inner.prepareCall(sql, resultSetType, resultSetConcurrency);
129     }
130     public CallableStatement JavaDoc prepareCall(String JavaDoc sql) throws SQLException JavaDoc {
131         return inner.prepareCall(sql);
132     }
133     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int resultSetType,
134             int resultSetConcurrency, int resultSetHoldability)
135             throws SQLException JavaDoc {
136         return inner.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
137     }
138     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int resultSetType,
139             int resultSetConcurrency) throws SQLException JavaDoc {
140         return inner.prepareStatement(sql, resultSetType, resultSetConcurrency);
141     }
142     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int autoGeneratedKeys)
143             throws SQLException JavaDoc {
144         return inner.prepareStatement(sql, autoGeneratedKeys);
145     }
146     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int[] columnIndexes)
147             throws SQLException JavaDoc {
148         return inner.prepareStatement(sql, columnIndexes);
149     }
150     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, String JavaDoc[] columnNames)
151             throws SQLException JavaDoc {
152         return inner.prepareStatement(sql, columnNames);
153     }
154     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql) throws SQLException JavaDoc {
155         return inner.prepareStatement(sql);
156     }
157     public void releaseSavepoint(Savepoint JavaDoc savepoint) throws SQLException JavaDoc {
158         throw new JDOUserException("Action forbidden on JDO connection");
159     }
160     public void rollback() throws SQLException JavaDoc {
161         throw new JDOUserException("Action forbidden on JDO connection");
162     }
163     public void rollback(Savepoint JavaDoc savepoint) throws SQLException JavaDoc {
164         throw new JDOUserException("Action forbidden on JDO connection");
165     }
166     public void setAutoCommit(boolean autoCommit) throws SQLException JavaDoc {
167         throw new JDOUserException("Action forbidden on JDO connection");
168     }
169     public void setCatalog(String JavaDoc catalog) throws SQLException JavaDoc {
170         throw new JDOUserException("Action forbidden on JDO connection");
171     }
172     public void setHoldability(int holdability) throws SQLException JavaDoc {
173         throw new JDOUserException("Action forbidden on JDO connection");
174     }
175     public void setReadOnly(boolean readOnly) throws SQLException JavaDoc {
176         throw new JDOUserException("Action forbidden on JDO connection");
177     }
178     public Savepoint JavaDoc setSavepoint() throws SQLException JavaDoc {
179         throw new JDOUserException("Action forbidden on JDO connection");
180     }
181     public Savepoint JavaDoc setSavepoint(String JavaDoc name) throws SQLException JavaDoc {
182         throw new JDOUserException("Action forbidden on JDO connection");
183     }
184     public void setTransactionIsolation(int level) throws SQLException JavaDoc {
185         throw new JDOUserException("Action forbidden on JDO connection");
186     }
187     public void setTypeMap(Map JavaDoc map) throws SQLException JavaDoc {
188         throw new JDOUserException("Action forbidden on JDO connection");
189     }
190 }
191
Popular Tags