001: /*
002:
003: Derby - Class org.apache.derby.client.net.NetStatement
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.net;
023:
024: import org.apache.derby.client.am.ColumnMetaData;
025: import org.apache.derby.client.am.Section;
026: import org.apache.derby.client.am.SqlException;
027: import org.apache.derby.client.am.Statement;
028: import org.apache.derby.jdbc.ClientDriver;
029:
030: public class NetStatement implements
031: org.apache.derby.client.am.MaterialStatement {
032:
033: Statement statement_;
034:
035: // Alias for (NetConnection) statement_.connection
036: NetConnection netConnection_;
037:
038: // Alias for (NetAgent) statement_.agent
039: NetAgent netAgent_;
040:
041: // If qryrowset is sent on opnqry then it also needs to be sent on every subsequent cntqry.
042: public boolean qryrowsetSentOnOpnqry_ = false;
043:
044: //---------------------constructors/finalizer---------------------------------
045:
046: private NetStatement() {
047: initNetStatement();
048: }
049:
050: private void resetNetStatement() {
051: initNetStatement();
052: }
053:
054: private void initNetStatement() {
055: qryrowsetSentOnOpnqry_ = false;
056: }
057:
058: // Relay constructor for NetPreparedStatement.
059: NetStatement(org.apache.derby.client.am.Statement statement,
060: NetAgent netAgent, NetConnection netConnection) {
061: this ();
062: initNetStatement(statement, netAgent, netConnection);
063: }
064:
065: void resetNetStatement(
066: org.apache.derby.client.am.Statement statement,
067: NetAgent netAgent, NetConnection netConnection) {
068: resetNetStatement();
069: initNetStatement(statement, netAgent, netConnection);
070: }
071:
072: private void initNetStatement(
073: org.apache.derby.client.am.Statement statement,
074: NetAgent netAgent, NetConnection netConnection) {
075: netAgent_ = netAgent;
076: netConnection_ = netConnection;
077: statement_ = statement;
078: statement_.materialStatement_ = this ;
079: }
080:
081: // Called by abstract Connection.createStatement().newStatement() for jdbc 1 statements
082: NetStatement(NetAgent netAgent, NetConnection netConnection)
083: throws SqlException {
084: this (ClientDriver.getFactory().newStatement(netAgent,
085: netConnection), netAgent, netConnection);
086: }
087:
088: void netReset(NetAgent netAgent, NetConnection netConnection)
089: throws SqlException {
090: statement_.resetStatement(netAgent, netConnection);
091: resetNetStatement(statement_, netAgent, netConnection);
092: }
093:
094: public void reset_() {
095: qryrowsetSentOnOpnqry_ = false;
096: }
097:
098: // Called by abstract Connection.createStatement().newStatement() for jdbc 2 statements with scroll attributes
099: NetStatement(NetAgent netAgent, NetConnection netConnection,
100: int type, int concurrency, int holdability)
101: throws SqlException {
102: this (ClientDriver.getFactory().newStatement(netAgent,
103: netConnection, type, concurrency, holdability,
104: java.sql.Statement.NO_GENERATED_KEYS, null), netAgent,
105: netConnection);
106: }
107:
108: void resetNetStatement(NetAgent netAgent,
109: NetConnection netConnection, int type, int concurrency,
110: int holdability) throws SqlException {
111: statement_.resetStatement(netAgent, netConnection, type,
112: concurrency, holdability,
113: java.sql.Statement.NO_GENERATED_KEYS, null);
114: resetNetStatement(statement_, netAgent, netConnection);
115: }
116:
117: protected void finalize() throws java.lang.Throwable {
118: super .finalize();
119: }
120:
121: // ------------------------abstract box car methods-----------------------------------------------
122:
123: public void writeSetSpecialRegister_(java.util.ArrayList sqlsttList)
124: throws SqlException {
125: netAgent_.statementRequest_.writeSetSpecialRegister(sqlsttList);
126: }
127:
128: public void readSetSpecialRegister_() throws SqlException {
129: netAgent_.statementReply_.readSetSpecialRegister(statement_);
130: }
131:
132: public void writeExecuteImmediate_(String sql, Section section)
133: throws SqlException {
134: netAgent_.statementRequest_.writeExecuteImmediate(this , sql,
135: section);
136: }
137:
138: public void readExecuteImmediate_() throws SqlException {
139: netAgent_.statementReply_.readExecuteImmediate(statement_);
140: }
141:
142: // NOTE: NET processing does not require parameters supplied on the "read-side" so parameter sql is ignored.
143: public void readExecuteImmediateForBatch_(String sql)
144: throws SqlException {
145: readExecuteImmediate_();
146: }
147:
148: public void writePrepareDescribeOutput_(String sql, Section section)
149: throws SqlException {
150: netAgent_.statementRequest_.writePrepareDescribeOutput(this ,
151: sql, section);
152: }
153:
154: public void readPrepareDescribeOutput_() throws SqlException {
155: netAgent_.statementReply_.readPrepareDescribeOutput(statement_);
156: }
157:
158: public void writeOpenQuery_(Section section, int fetchSize,
159: int resultSetType) throws SqlException {
160: netAgent_.statementRequest_.writeOpenQuery(this , section,
161: fetchSize, resultSetType);
162: }
163:
164: public void readOpenQuery_() throws SqlException {
165: netAgent_.statementReply_.readOpenQuery(statement_);
166: }
167:
168: public void writeExecuteCall_(boolean outputExpected,
169: String procedureName, Section section, int fetchSize,
170: boolean suppressResultSets, int resultSetType,
171: ColumnMetaData parameterMetaData, Object[] inputs)
172: throws SqlException {
173: netAgent_.statementRequest_.writeExecuteCall(this ,
174: outputExpected, procedureName, section, fetchSize,
175: suppressResultSets, resultSetType, parameterMetaData,
176: inputs);
177: }
178:
179: public void readExecuteCall_() throws SqlException {
180: netAgent_.statementReply_.readExecuteCall(statement_);
181: }
182:
183: public void writePrepare_(String sql, Section section)
184: throws SqlException {
185: netAgent_.statementRequest_.writePrepare(this , sql, section);
186: }
187:
188: public void readPrepare_() throws SqlException {
189: netAgent_.statementReply_.readPrepare(statement_);
190: }
191:
192: public void markClosedOnServer_() {
193: }
194: }
|