KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > dbcp > TesterPreparedStatement


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.commons.dbcp;
18
19 import java.math.BigDecimal JavaDoc;
20 import java.sql.Array JavaDoc;
21 import java.sql.Blob JavaDoc;
22 import java.sql.Clob JavaDoc;
23 import java.sql.Connection JavaDoc;
24 import java.sql.PreparedStatement JavaDoc;
25 import java.sql.Ref JavaDoc;
26 import java.sql.ResultSet JavaDoc;
27 import java.sql.ResultSetMetaData JavaDoc;
28 import java.sql.SQLException JavaDoc;
29 import java.util.Calendar JavaDoc;
30
31 /**
32  * A dummy {@link PreparedStatement}, for testing purposes.
33  *
34  * @author Rodney Waldhoff
35  * @author Dirk Verbeeck
36  * @version $Revision: 1.12 $ $Date: 2004/03/07 15:28:36 $
37  */

38 public class TesterPreparedStatement extends TesterStatement implements PreparedStatement JavaDoc {
39     private ResultSetMetaData JavaDoc _resultSetMetaData = null;
40     private String JavaDoc _sql = null;
41     private String JavaDoc _catalog = null;
42
43     public TesterPreparedStatement(Connection JavaDoc conn) {
44         super(conn);
45         try {
46             _catalog = conn.getCatalog();
47         } catch (SQLException JavaDoc e) { }
48     }
49
50     public TesterPreparedStatement(Connection JavaDoc conn, String JavaDoc sql) {
51         super(conn);
52         _sql = sql;
53         try {
54             _catalog = conn.getCatalog();
55         } catch (SQLException JavaDoc e) { }
56     }
57
58     public TesterPreparedStatement(Connection JavaDoc conn, String JavaDoc sql, int resultSetType, int resultSetConcurrency) {
59         super(conn, resultSetType, resultSetConcurrency);
60         _sql = sql;
61         try {
62             _catalog = conn.getCatalog();
63         } catch (SQLException JavaDoc e) { }
64     }
65     
66     /** for junit test only */
67     public String JavaDoc getCatalog() {
68         return _catalog;
69     }
70
71     public ResultSet JavaDoc executeQuery(String JavaDoc sql) throws SQLException JavaDoc {
72         checkOpen();
73         if("null".equals(sql)) {
74             return null;
75         } else {
76             return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
77         }
78     }
79
80     public int executeUpdate(String JavaDoc sql) throws SQLException JavaDoc {
81         checkOpen();
82         return _rowsUpdated;
83     }
84
85     public ResultSet JavaDoc executeQuery() throws SQLException JavaDoc {
86         checkOpen();
87         if("null".equals(_sql)) {
88             return null;
89         } else {
90             return new TesterResultSet(this, null, _resultSetType, _resultSetConcurrency);
91         }
92     }
93
94     public int executeUpdate() throws SQLException JavaDoc {
95         checkOpen();
96         return _rowsUpdated;
97     }
98
99     public void setNull(int parameterIndex, int sqlType) throws SQLException JavaDoc {
100         checkOpen();
101     }
102
103     public void setBoolean(int parameterIndex, boolean x) throws SQLException JavaDoc {
104         checkOpen();
105     }
106
107     public void setByte(int parameterIndex, byte x) throws SQLException JavaDoc {
108         checkOpen();
109     }
110
111     public void setShort(int parameterIndex, short x) throws SQLException JavaDoc {
112         checkOpen();
113     }
114
115     public void setInt(int parameterIndex, int x) throws SQLException JavaDoc {
116         checkOpen();
117     }
118
119     public void setLong(int parameterIndex, long x) throws SQLException JavaDoc {
120         checkOpen();
121     }
122
123     public void setFloat(int parameterIndex, float x) throws SQLException JavaDoc {
124         checkOpen();
125     }
126
127     public void setDouble(int parameterIndex, double x) throws SQLException JavaDoc {
128         checkOpen();
129     }
130
131     public void setBigDecimal(int parameterIndex, BigDecimal JavaDoc x) throws SQLException JavaDoc {
132         checkOpen();
133     }
134
135     public void setString(int parameterIndex, String JavaDoc x) throws SQLException JavaDoc {
136         checkOpen();
137     }
138
139     public void setBytes(int parameterIndex, byte x[]) throws SQLException JavaDoc {
140         checkOpen();
141     }
142
143     public void setDate(int parameterIndex, java.sql.Date JavaDoc x) throws SQLException JavaDoc {
144         checkOpen();
145     }
146
147     public void setTime(int parameterIndex, java.sql.Time JavaDoc x) throws SQLException JavaDoc {
148         checkOpen();
149     }
150
151     public void setTimestamp(int parameterIndex, java.sql.Timestamp JavaDoc x) throws SQLException JavaDoc {
152         checkOpen();
153     }
154
155     public void setAsciiStream(int parameterIndex, java.io.InputStream JavaDoc x, int length) throws SQLException JavaDoc {
156         checkOpen();
157     }
158
159     /** @deprecated */
160     public void setUnicodeStream(int parameterIndex, java.io.InputStream JavaDoc x, int length) throws SQLException JavaDoc {
161         checkOpen();
162     }
163
164     public void setBinaryStream(int parameterIndex, java.io.InputStream JavaDoc x, int length) throws SQLException JavaDoc {
165         checkOpen();
166     }
167
168     public void clearParameters() throws SQLException JavaDoc {
169         checkOpen();
170     }
171
172     public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType, int scale) throws SQLException JavaDoc {
173         checkOpen();
174     }
175
176     public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType) throws SQLException JavaDoc {
177         checkOpen();
178     }
179
180     public void setObject(int parameterIndex, Object JavaDoc x) throws SQLException JavaDoc {
181         checkOpen();
182     }
183
184
185     public boolean execute() throws SQLException JavaDoc {
186         checkOpen(); return true;
187     }
188
189     public void addBatch() throws SQLException JavaDoc {
190         checkOpen();
191     }
192
193     public void setCharacterStream(int parameterIndex, java.io.Reader JavaDoc reader, int length) throws SQLException JavaDoc {
194         checkOpen();
195     }
196
197     public void setRef (int i, Ref JavaDoc x) throws SQLException JavaDoc {
198         checkOpen();
199     }
200
201     public void setBlob (int i, Blob JavaDoc x) throws SQLException JavaDoc {
202         checkOpen();
203     }
204
205     public void setClob (int i, Clob JavaDoc x) throws SQLException JavaDoc {
206         checkOpen();
207     }
208
209     public void setArray (int i, Array JavaDoc x) throws SQLException JavaDoc {
210         checkOpen();
211     }
212
213     public ResultSetMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
214         checkOpen();
215         return _resultSetMetaData;
216     }
217
218     public void setDate(int parameterIndex, java.sql.Date JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
219         checkOpen();
220     }
221
222     public void setTime(int parameterIndex, java.sql.Time JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
223         checkOpen();
224     }
225
226     public void setTimestamp(int parameterIndex, java.sql.Timestamp JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
227         checkOpen();
228     }
229
230     public void setNull (int paramIndex, int sqlType, String JavaDoc typeName) throws SQLException JavaDoc {
231         checkOpen();
232     }
233
234
235     // ------------------- JDBC 3.0 -----------------------------------------
236
// Will be commented by the build process on a JDBC 2.0 system
237

238 /* JDBC_3_ANT_KEY_BEGIN */
239
240     public boolean getMoreResults(int current) throws SQLException JavaDoc {
241         throw new SQLException JavaDoc("Not implemented.");
242     }
243
244     public ResultSet JavaDoc getGeneratedKeys() throws SQLException JavaDoc {
245         throw new SQLException JavaDoc("Not implemented.");
246     }
247
248     public int executeUpdate(String JavaDoc sql, int autoGeneratedKeys)
249         throws SQLException JavaDoc {
250         throw new SQLException JavaDoc("Not implemented.");
251     }
252
253     public int executeUpdate(String JavaDoc sql, int columnIndexes[])
254         throws SQLException JavaDoc {
255         throw new SQLException JavaDoc("Not implemented.");
256     }
257
258     public int executeUpdate(String JavaDoc sql, String JavaDoc columnNames[])
259         throws SQLException JavaDoc {
260         throw new SQLException JavaDoc("Not implemented.");
261     }
262
263     public boolean execute(String JavaDoc sql, int autoGeneratedKeys)
264         throws SQLException JavaDoc {
265         throw new SQLException JavaDoc("Not implemented.");
266     }
267
268     public boolean execute(String JavaDoc sl, int columnIndexes[])
269         throws SQLException JavaDoc {
270         throw new SQLException JavaDoc("Not implemented.");
271     }
272
273     public boolean execute(String JavaDoc sql, String JavaDoc columnNames[])
274         throws SQLException JavaDoc {
275         throw new SQLException JavaDoc("Not implemented.");
276     }
277
278     public int getResultSetHoldability() throws SQLException JavaDoc {
279         throw new SQLException JavaDoc("Not implemented.");
280     }
281
282     public void setURL(int parameterIndex, java.net.URL JavaDoc x)
283         throws SQLException JavaDoc {
284         throw new SQLException JavaDoc("Not implemented.");
285     }
286
287     public java.sql.ParameterMetaData JavaDoc getParameterMetaData() throws SQLException JavaDoc {
288         throw new SQLException JavaDoc("Not implemented.");
289     }
290
291 /* JDBC_3_ANT_KEY_END */
292
293 }
294
Popular Tags