001: /*
002:
003: Derby - Class org.apache.derby.iapi.jdbc.BrokeredPreparedStatement40
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.jdbc;
023:
024: import java.io.InputStream;
025: import java.io.Reader;
026: import java.sql.NClob;
027: import java.sql.RowId;
028: import java.sql.SQLException;
029: import java.sql.SQLXML;
030: import org.apache.derby.impl.jdbc.Util;
031: import org.apache.derby.iapi.reference.SQLState;
032:
033: public class BrokeredPreparedStatement40 extends
034: BrokeredPreparedStatement30 {
035:
036: public BrokeredPreparedStatement40(
037: BrokeredStatementControl control, int jdbcLevel,
038: String sql, Object generatedKeys) throws SQLException {
039: super (control, jdbcLevel, sql, generatedKeys);
040: }
041:
042: public void setRowId(int parameterIndex, RowId x)
043: throws SQLException {
044: getPreparedStatement().setRowId(parameterIndex, x);
045: }
046:
047: public void setNString(int index, String value) throws SQLException {
048: getPreparedStatement().setNString(index, value);
049: }
050:
051: public void setNCharacterStream(int parameterIndex, Reader value)
052: throws SQLException {
053: getPreparedStatement().setNCharacterStream(parameterIndex,
054: value);
055: }
056:
057: public void setNCharacterStream(int index, Reader value, long length)
058: throws SQLException {
059: getPreparedStatement()
060: .setNCharacterStream(index, value, length);
061: }
062:
063: public void setNClob(int index, NClob value) throws SQLException {
064: getPreparedStatement().setNClob(index, value);
065: }
066:
067: public void setClob(int parameterIndex, Reader reader, long length)
068: throws SQLException {
069: getPreparedStatement().setClob(parameterIndex, reader, length);
070: }
071:
072: public void setBlob(int parameterIndex, InputStream inputStream,
073: long length) throws SQLException {
074: getPreparedStatement().setBlob(parameterIndex, inputStream,
075: length);
076: }
077:
078: public final void setNClob(int parameterIndex, Reader reader)
079: throws SQLException {
080: getPreparedStatement().setNClob(parameterIndex, reader);
081: }
082:
083: public void setNClob(int parameterIndex, Reader reader, long length)
084: throws SQLException {
085: getPreparedStatement().setNClob(parameterIndex, reader, length);
086: }
087:
088: public void setSQLXML(int parameterIndex, SQLXML xmlObject)
089: throws SQLException {
090: getPreparedStatement().setSQLXML(parameterIndex, xmlObject);
091: }
092:
093: /**
094: * Checks if the statement is closed.
095: *
096: * @return <code>true</code> if the statement is closed,
097: * <code>false</code> otherwise
098: * @exception SQLException if an error occurs
099: */
100: public final boolean isClosed() throws SQLException {
101: return getPreparedStatement().isClosed();
102: }
103:
104: /**
105: * Returns <code>this</code> if this class implements the interface
106: *
107: * @param interfaces a Class defining an interface
108: * @return an object that implements the interface
109: * @throws java.sql.SQLExption if no object if found that implements the
110: * interface
111: */
112: public <T> T unwrap(java.lang.Class<T> interfaces)
113: throws SQLException {
114: checkIfClosed();
115: //Derby does not implement non-standard methods on
116: //JDBC objects
117: try {
118: return interfaces.cast(this );
119: } catch (ClassCastException cce) {
120: throw Util.generateCsSQLException(
121: SQLState.UNABLE_TO_UNWRAP, interfaces);
122: }
123: }
124:
125: /**
126: * Forwards to the real PreparedStatement.
127: * @return true if the underlying PreparedStatement is poolable,
128: * false otherwise.
129: * @throws SQLException if the forwarding call fails.
130: */
131: public boolean isPoolable() throws SQLException {
132: return getStatement().isPoolable();
133: }
134:
135: /**
136: * Forwards to the real PreparedStatement.
137: * @param poolable the new value for the poolable hint.
138: * @throws SQLException if the forwarding call fails.
139: */
140: public void setPoolable(boolean poolable) throws SQLException {
141: getStatement().setPoolable(poolable);
142: }
143:
144: /**
145: * Sets the designated parameter to the given input stream.
146: *
147: * @param parameterIndex the first parameter is 1, the second is 2, ...
148: * @param x the Java input stream that contains the ASCII parameter value
149: * @throws SQLException if a database access error occurs or this method is
150: * called on a closed <code>PreparedStatement</code>
151: */
152: public final void setAsciiStream(int parameterIndex, InputStream x)
153: throws SQLException {
154: getPreparedStatement().setAsciiStream(parameterIndex, x);
155: }
156:
157: /**
158: * Sets the designated parameter to the given input stream, which will have
159: * the specified number of bytes.
160: *
161: * @param parameterIndex the first parameter is 1, the second is 2, ...
162: * @param x the java input stream which contains the ASCII parameter value
163: * @param length the number of bytes in the stream
164: * @exception SQLException thrown on failure.
165: *
166: */
167:
168: public final void setAsciiStream(int parameterIndex, InputStream x,
169: long length) throws SQLException {
170: getPreparedStatement()
171: .setAsciiStream(parameterIndex, x, length);
172: }
173:
174: /**
175: * Sets the designated parameter to the given input stream.
176: *
177: * @param parameterIndex the first parameter is 1, the second is 2, ...
178: * @param x the java input stream which contains the binary parameter value
179: * @throws SQLException if a database access error occurs or this method is
180: * called on a closed <code>PreparedStatement</code>
181: */
182: public final void setBinaryStream(int parameterIndex, InputStream x)
183: throws SQLException {
184: getPreparedStatement().setBinaryStream(parameterIndex, x);
185: }
186:
187: /**
188: * Sets the designated parameter to the given input stream, which will have
189: * the specified number of bytes.
190: *
191: * @param parameterIndex the first parameter is 1, the second is 2, ...
192: * @param x the java input stream which contains the binary parameter value
193: * @param length the number of bytes in the stream
194: * @exception SQLException thrown on failure.
195: *
196: */
197:
198: public final void setBinaryStream(int parameterIndex,
199: InputStream x, long length) throws SQLException {
200: getPreparedStatement().setBinaryStream(parameterIndex, x,
201: length);
202: }
203:
204: /**
205: * Sets the designated parameter to a <code>InputStream</code> object.
206: * This method differs from the <code>setBinaryStream(int, InputStream)
207: * </code> method because it informs the driver that the parameter value
208: * should be sent to the server as a <code>BLOB</code>.
209: *
210: * @param inputStream an object that contains the data to set the parameter
211: * value to.
212: * @throws SQLException if a database access error occurs, this method is
213: * called on a closed <code>PreparedStatement</code>
214: */
215: public final void setBlob(int parameterIndex,
216: InputStream inputStream) throws SQLException {
217: getPreparedStatement().setBlob(parameterIndex, inputStream);
218: }
219:
220: /**
221: * Sets the designated parameter to the given <code>Reader</code> object.
222: *
223: * @param parameterIndex the first parameter is 1, the second is 2, ...
224: * @param reader the <code>java.io.Reader</code> object that contains the
225: * Unicode data
226: * @throws SQLException if a database access error occurs or this method is
227: * called on a closed <code>PreparedStatement</code>
228: */
229: public final void setCharacterStream(int parameterIndex,
230: Reader reader) throws SQLException {
231: getPreparedStatement().setCharacterStream(parameterIndex,
232: reader);
233: }
234:
235: /**
236: * Sets the designated parameter to the given Reader, which will have
237: * the specified number of bytes.
238: *
239: * @param parameterIndex the first parameter is 1, the second is 2, ...
240: * @param x the java Reader which contains the UNICODE value
241: * @param length the number of bytes in the stream
242: * @exception SQLException thrown on failure.
243: *
244: */
245:
246: public final void setCharacterStream(int parameterIndex, Reader x,
247: long length) throws SQLException {
248: getPreparedStatement().setCharacterStream(parameterIndex, x,
249: length);
250: }
251:
252: /**
253: * Sets the designated parameter to a <code>Reader</code> object.
254: * This method differs from the <code>setCharacterStream(int,Reader)</code>
255: * method because it informs the driver that the parameter value should be
256: * sent to the server as a <code>CLOB</code>.
257: *
258: * @param parameterIndex the first parameter is 1, the second is 2, ...
259: * @param reader an object that contains the data to set the parameter
260: * value to.
261: * @throws SQLException if a database access error occurs, this method is
262: * called on a closed PreparedStatement
263: */
264: public final void setClob(int parameterIndex, Reader reader)
265: throws SQLException {
266: getPreparedStatement().setClob(parameterIndex, reader);
267: }
268: }
|