001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.commons.dbcp;
019:
020: import java.math.BigDecimal;
021: import java.sql.Array;
022: import java.sql.Blob;
023: import java.sql.Clob;
024: import java.sql.Connection;
025: import java.sql.PreparedStatement;
026: import java.sql.Ref;
027: import java.sql.ResultSet;
028: import java.sql.ResultSetMetaData;
029: import java.sql.SQLException;
030: import java.util.Calendar;
031:
032: /**
033: * A dummy {@link PreparedStatement}, for testing purposes.
034: *
035: * @author Rodney Waldhoff
036: * @author Dirk Verbeeck
037: * @version $Revision: 479137 $ $Date: 2006-11-25 08:51:48 -0700 (Sat, 25 Nov 2006) $
038: */
039: public class TesterPreparedStatement extends TesterStatement implements
040: PreparedStatement {
041: private ResultSetMetaData _resultSetMetaData = null;
042: private String _sql = null;
043: private String _catalog = null;
044:
045: public TesterPreparedStatement(Connection conn) {
046: super (conn);
047: try {
048: _catalog = conn.getCatalog();
049: } catch (SQLException e) {
050: }
051: }
052:
053: public TesterPreparedStatement(Connection conn, String sql) {
054: super (conn);
055: _sql = sql;
056: try {
057: _catalog = conn.getCatalog();
058: } catch (SQLException e) {
059: }
060: }
061:
062: public TesterPreparedStatement(Connection conn, String sql,
063: int resultSetType, int resultSetConcurrency) {
064: super (conn, resultSetType, resultSetConcurrency);
065: _sql = sql;
066: try {
067: _catalog = conn.getCatalog();
068: } catch (SQLException e) {
069: }
070: }
071:
072: /** for junit test only */
073: public String getCatalog() {
074: return _catalog;
075: }
076:
077: public ResultSet executeQuery(String sql) throws SQLException {
078: checkOpen();
079: if ("null".equals(sql)) {
080: return null;
081: } else {
082: return new TesterResultSet(this , null, _resultSetType,
083: _resultSetConcurrency);
084: }
085: }
086:
087: public int executeUpdate(String sql) throws SQLException {
088: checkOpen();
089: return _rowsUpdated;
090: }
091:
092: public ResultSet executeQuery() throws SQLException {
093: checkOpen();
094: if ("null".equals(_sql)) {
095: return null;
096: } else {
097: return new TesterResultSet(this , null, _resultSetType,
098: _resultSetConcurrency);
099: }
100: }
101:
102: public int executeUpdate() throws SQLException {
103: checkOpen();
104: return _rowsUpdated;
105: }
106:
107: public void setNull(int parameterIndex, int sqlType)
108: throws SQLException {
109: checkOpen();
110: }
111:
112: public void setBoolean(int parameterIndex, boolean x)
113: throws SQLException {
114: checkOpen();
115: }
116:
117: public void setByte(int parameterIndex, byte x) throws SQLException {
118: checkOpen();
119: }
120:
121: public void setShort(int parameterIndex, short x)
122: throws SQLException {
123: checkOpen();
124: }
125:
126: public void setInt(int parameterIndex, int x) throws SQLException {
127: checkOpen();
128: }
129:
130: public void setLong(int parameterIndex, long x) throws SQLException {
131: checkOpen();
132: }
133:
134: public void setFloat(int parameterIndex, float x)
135: throws SQLException {
136: checkOpen();
137: }
138:
139: public void setDouble(int parameterIndex, double x)
140: throws SQLException {
141: checkOpen();
142: }
143:
144: public void setBigDecimal(int parameterIndex, BigDecimal x)
145: throws SQLException {
146: checkOpen();
147: }
148:
149: public void setString(int parameterIndex, String x)
150: throws SQLException {
151: checkOpen();
152: }
153:
154: public void setBytes(int parameterIndex, byte x[])
155: throws SQLException {
156: checkOpen();
157: }
158:
159: public void setDate(int parameterIndex, java.sql.Date x)
160: throws SQLException {
161: checkOpen();
162: }
163:
164: public void setTime(int parameterIndex, java.sql.Time x)
165: throws SQLException {
166: checkOpen();
167: }
168:
169: public void setTimestamp(int parameterIndex, java.sql.Timestamp x)
170: throws SQLException {
171: checkOpen();
172: }
173:
174: public void setAsciiStream(int parameterIndex,
175: java.io.InputStream x, int length) throws SQLException {
176: checkOpen();
177: }
178:
179: /** @deprecated */
180: public void setUnicodeStream(int parameterIndex,
181: java.io.InputStream x, int length) throws SQLException {
182: checkOpen();
183: }
184:
185: public void setBinaryStream(int parameterIndex,
186: java.io.InputStream x, int length) throws SQLException {
187: checkOpen();
188: }
189:
190: public void clearParameters() throws SQLException {
191: checkOpen();
192: }
193:
194: public void setObject(int parameterIndex, Object x,
195: int targetSqlType, int scale) throws SQLException {
196: checkOpen();
197: }
198:
199: public void setObject(int parameterIndex, Object x,
200: int targetSqlType) throws SQLException {
201: checkOpen();
202: }
203:
204: public void setObject(int parameterIndex, Object x)
205: throws SQLException {
206: checkOpen();
207: }
208:
209: public boolean execute() throws SQLException {
210: checkOpen();
211: return true;
212: }
213:
214: public void addBatch() throws SQLException {
215: checkOpen();
216: }
217:
218: public void setCharacterStream(int parameterIndex,
219: java.io.Reader reader, int length) throws SQLException {
220: checkOpen();
221: }
222:
223: public void setRef(int i, Ref x) throws SQLException {
224: checkOpen();
225: }
226:
227: public void setBlob(int i, Blob x) throws SQLException {
228: checkOpen();
229: }
230:
231: public void setClob(int i, Clob x) throws SQLException {
232: checkOpen();
233: }
234:
235: public void setArray(int i, Array x) throws SQLException {
236: checkOpen();
237: }
238:
239: public ResultSetMetaData getMetaData() throws SQLException {
240: checkOpen();
241: return _resultSetMetaData;
242: }
243:
244: public void setDate(int parameterIndex, java.sql.Date x,
245: Calendar cal) throws SQLException {
246: checkOpen();
247: }
248:
249: public void setTime(int parameterIndex, java.sql.Time x,
250: Calendar cal) throws SQLException {
251: checkOpen();
252: }
253:
254: public void setTimestamp(int parameterIndex, java.sql.Timestamp x,
255: Calendar cal) throws SQLException {
256: checkOpen();
257: }
258:
259: public void setNull(int paramIndex, int sqlType, String typeName)
260: throws SQLException {
261: checkOpen();
262: }
263:
264: // ------------------- JDBC 3.0 -----------------------------------------
265: // Will be commented by the build process on a JDBC 2.0 system
266:
267: /* JDBC_3_ANT_KEY_BEGIN */
268:
269: public boolean getMoreResults(int current) throws SQLException {
270: throw new SQLException("Not implemented.");
271: }
272:
273: public ResultSet getGeneratedKeys() throws SQLException {
274: throw new SQLException("Not implemented.");
275: }
276:
277: public int executeUpdate(String sql, int autoGeneratedKeys)
278: throws SQLException {
279: throw new SQLException("Not implemented.");
280: }
281:
282: public int executeUpdate(String sql, int columnIndexes[])
283: throws SQLException {
284: throw new SQLException("Not implemented.");
285: }
286:
287: public int executeUpdate(String sql, String columnNames[])
288: throws SQLException {
289: throw new SQLException("Not implemented.");
290: }
291:
292: public boolean execute(String sql, int autoGeneratedKeys)
293: throws SQLException {
294: throw new SQLException("Not implemented.");
295: }
296:
297: public boolean execute(String sl, int columnIndexes[])
298: throws SQLException {
299: throw new SQLException("Not implemented.");
300: }
301:
302: public boolean execute(String sql, String columnNames[])
303: throws SQLException {
304: throw new SQLException("Not implemented.");
305: }
306:
307: public int getResultSetHoldability() throws SQLException {
308: throw new SQLException("Not implemented.");
309: }
310:
311: public void setURL(int parameterIndex, java.net.URL x)
312: throws SQLException {
313: throw new SQLException("Not implemented.");
314: }
315:
316: public java.sql.ParameterMetaData getParameterMetaData()
317: throws SQLException {
318: throw new SQLException("Not implemented.");
319: }
320:
321: /* JDBC_3_ANT_KEY_END */
322:
323: }
|