001: /*
002:
003: Derby - Class org.apache.derby.client.am.PreparedStatement40
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.client.am;
023:
024: import java.sql.RowId;
025: import java.sql.NClob;
026: import java.sql.SQLException;
027: import java.sql.SQLXML;
028: import java.io.Reader;
029: import java.io.InputStream;
030: import org.apache.derby.client.ClientPooledConnection;
031: import org.apache.derby.client.am.SqlException;
032: import org.apache.derby.client.am.ClientMessageId;
033: import org.apache.derby.shared.common.reference.SQLState;
034:
035: public class PreparedStatement40 extends
036: org.apache.derby.client.am.PreparedStatement {
037:
038: /**
039: * The PreparedStatement used for JDBC 4 positioned update statements.
040: * Called by material statement constructors.
041: * It has the ClientPooledConnection as one of its parameters
042: * this is used to raise the Statement Events when the prepared
043: * statement is closed
044: *
045: * @param agent The instance of NetAgent associated with this
046: * CallableStatement object.
047: * @param connection The connection object associated with this
048: * PreparedStatement Object.
049: * @param sql A String object that is the SQL statement to be sent
050: * to the database.
051: * @param section Section
052: * @param cpc The ClientPooledConnection wraps the underlying physical
053: * connection associated with this prepared statement.
054: * It is used to pass the Statement closed and the Statement
055: * error occurred events that occur back to the
056: * ClientPooledConnection.
057: * @throws SqlException
058: */
059: public PreparedStatement40(Agent agent, Connection connection,
060: String sql, Section section, ClientPooledConnection cpc)
061: throws SqlException {
062: super (agent, connection, sql, section, cpc);
063: }
064:
065: /**
066: * The PreparedStatementConstructor used for jdbc 4 prepared statements
067: * with scroll attributes. Called by material statement constructors.
068: * It has the ClientPooledConnection as one of its parameters
069: * this is used to raise the Statement Events when the prepared
070: * statement is closed
071: *
072: * @param agent The instance of NetAgent associated with this
073: * CallableStatement object.
074: * @param connection The connection object associated with this
075: * PreparedStatement Object.
076: * @param sql A String object that is the SQL statement
077: * to be sent to the database.
078: * @param type One of the ResultSet type constants.
079: * @param concurrency One of the ResultSet concurrency constants.
080: * @param holdability One of the ResultSet holdability constants.
081: * @param autoGeneratedKeys a flag indicating whether auto-generated
082: * keys should be returned.
083: * @param columnNames an array of column names indicating the columns that
084: * should be returned from the inserted row or rows.
085: * @param cpc The ClientPooledConnection wraps the underlying physical
086: * connection associated with this prepared statement
087: * it is used to pass the Statement closed and the Statement
088: * error occurred events that occur back to the
089: * ClientPooledConnection.
090: * @throws SqlException
091: */
092: public PreparedStatement40(Agent agent, Connection connection,
093: String sql, int type, int concurrency, int holdability,
094: int autoGeneratedKeys, String[] columnNames,
095: ClientPooledConnection cpc) throws SqlException {
096: super (agent, connection, sql, type, concurrency, holdability,
097: autoGeneratedKeys, columnNames, cpc);
098: }
099:
100: public void setRowId(int parameterIndex, RowId x)
101: throws SQLException {
102: throw SQLExceptionFactory
103: .notImplemented("setRowId (int, RowId)");
104: }
105:
106: public void setNString(int index, String value) throws SQLException {
107: throw SQLExceptionFactory
108: .notImplemented("setNString (int, String)");
109: }
110:
111: public void setNCharacterStream(int parameterIndex, Reader value)
112: throws SQLException {
113: throw SQLExceptionFactory.notImplemented("setNCharacterStream"
114: + "(int,Reader)");
115: }
116:
117: public void setNCharacterStream(int index, Reader value, long length)
118: throws SQLException {
119: throw SQLExceptionFactory.notImplemented("setNCharacterStream "
120: + "(int,Reader,long)");
121: }
122:
123: public void setNClob(int parameterIndex, Reader reader)
124: throws SQLException {
125: throw SQLExceptionFactory
126: .notImplemented("setNClob(int,Reader)");
127: }
128:
129: public void setNClob(int index, NClob value) throws SQLException {
130: throw SQLExceptionFactory
131: .notImplemented("setNClob (int, NClob)");
132: }
133:
134: public void setNClob(int parameterIndex, Reader reader, long length)
135: throws SQLException {
136: throw SQLExceptionFactory
137: .notImplemented("setNClob (int, Reader, long)");
138: }
139:
140: public void setSQLXML(int parameterIndex, SQLXML xmlObject)
141: throws SQLException {
142: throw SQLExceptionFactory
143: .notImplemented("setSQLXML (int, SQLXML)");
144: }
145:
146: /**
147: * Returns <code>this</code> if this class implements the interface
148: *
149: * @param interfaces a Class defining an interface
150: * @return an object that implements the interface
151: * @throws java.sql.SQLExption if no object if found that implements the
152: * interface
153: */
154: public <T> T unwrap(java.lang.Class<T> interfaces)
155: throws SQLException {
156: try {
157: checkForClosedStatement();
158: return interfaces.cast(this );
159: } catch (ClassCastException cce) {
160: throw new SqlException(null, new ClientMessageId(
161: SQLState.UNABLE_TO_UNWRAP), interfaces)
162: .getSQLException();
163: } catch (SqlException se) {
164: throw se.getSQLException();
165: }
166: }
167: }
|