001 /*
002
003 Derby - Class org.apache.derby.client.net.NetStatement
004
005 Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable.
006
007 Licensed under the Apache License, Version 2.0 (the "License");
008 you may not use this file except in compliance with the License.
009 You may obtain a copy of the License at
010
011 http://www.apache.org/licenses/LICENSE-2.0
012
013 Unless required by applicable law or agreed to in writing, software
014 distributed under the License is distributed on an "AS IS" BASIS,
015 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 See the License for the specific language governing permissions and
017 limitations under the License.
018
019 */
020
021 package org.apache.derby.client.net;
022
023 import org.apache.derby.client.am.ColumnMetaData;
024 import org.apache.derby.client.am.Section;
025 import org.apache.derby.client.am.SqlException;
026 import org.apache.derby.client.am.Statement;
027
028 public class NetStatement implements org.apache.derby.client.am.MaterialStatement {
029
030 Statement statement_;
031
032
033 // Alias for (NetConnection) statement_.connection
034 NetConnection netConnection_;
035
036 // Alias for (NetAgent) statement_.agent
037 NetAgent netAgent_;
038
039
040 // If qryrowset is sent on opnqry then it also needs to be sent on every subsequent cntqry.
041 public boolean qryrowsetSentOnOpnqry_ = false;
042
043 //---------------------constructors/finalizer---------------------------------
044
045 private NetStatement() {
046 initNetStatement();
047 }
048
049 private void resetNetStatement() {
050 initNetStatement();
051 }
052
053 private void initNetStatement() {
054 qryrowsetSentOnOpnqry_ = false;
055 }
056
057 // Relay constructor for NetPreparedStatement.
058 NetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) {
059 this();
060 initNetStatement(statement, netAgent, netConnection);
061 }
062
063 void resetNetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) {
064 resetNetStatement();
065 initNetStatement(statement, netAgent, netConnection);
066 }
067
068 private void initNetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) {
069 netAgent_ = netAgent;
070 netConnection_ = netConnection;
071 statement_ = statement;
072 statement_.materialStatement_ = this;
073 }
074
075 // Called by abstract Connection.createStatement().newStatement() for jdbc 1 statements
076 NetStatement(NetAgent netAgent, NetConnection netConnection) throws SqlException {
077 this(new Statement(netAgent, netConnection),
078 netAgent,
079 netConnection);
080 }
081
082 void netReset(NetAgent netAgent, NetConnection netConnection) throws SqlException {
083 statement_.resetStatement(netAgent, netConnection);
084 resetNetStatement(statement_, netAgent, netConnection);
085 }
086
087 public void reset_() {
088 qryrowsetSentOnOpnqry_ = false;
089 }
090
091 // Called by abstract Connection.createStatement().newStatement() for jdbc 2 statements with scroll attributes
092 NetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException {
093 this(new Statement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null),
094 netAgent,
095 netConnection);
096 }
097
098 void resetNetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException {
099 statement_.resetStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null);
100 resetNetStatement(statement_, netAgent, netConnection);
101 }
102
103 protected void finalize() throws java.lang.Throwable {
104 super.finalize();
105 }
106
107 // ------------------------abstract box car methods-----------------------------------------------
108
109 public void writeSetSpecialRegister_(java.util.ArrayList sqlsttList) throws SqlException {
110 netAgent_.statementRequest_.writeSetSpecialRegister(sqlsttList);
111 }
112
113 public void readSetSpecialRegister_() throws SqlException {
114 netAgent_.statementReply_.readSetSpecialRegister(statement_);
115 }
116
117 public void writeExecuteImmediate_(String sql,
118 Section section) throws SqlException {
119 netAgent_.statementRequest_.writeExecuteImmediate(this, sql, section);
120 }
121
122 public void readExecuteImmediate_() throws SqlException {
123 netAgent_.statementReply_.readExecuteImmediate(statement_);
124 }
125
126 // NOTE: NET processing does not require parameters supplied on the "read-side" so parameter sql is ignored.
127 public void readExecuteImmediateForBatch_(String sql) throws SqlException {
128 readExecuteImmediate_();
129 }
130
131 public void writePrepareDescribeOutput_(String sql,
132 Section section) throws SqlException {
133 netAgent_.statementRequest_.writePrepareDescribeOutput(this, sql, section);
134 }
135
136 public void readPrepareDescribeOutput_() throws SqlException {
137 netAgent_.statementReply_.readPrepareDescribeOutput(statement_);
138 }
139
140 public void writeOpenQuery_(Section section,
141 int fetchSize,
142 int resultSetType)
143 throws SqlException {
144 netAgent_.statementRequest_.writeOpenQuery(this,
145 section,
146 fetchSize,
147 resultSetType);
148 }
149
150 public void readOpenQuery_() throws SqlException {
151 netAgent_.statementReply_.readOpenQuery(statement_);
152 }
153
154 public void writeExecuteCall_(boolean outputExpected,
155 String procedureName,
156 Section section,
157 int fetchSize,
158 boolean suppressResultSets,
159 int resultSetType,
160 ColumnMetaData parameterMetaData,
161 Object[] inputs) throws SqlException {
162 netAgent_.statementRequest_.writeExecuteCall(this,
163 outputExpected,
164 procedureName,
165 section,
166 fetchSize,
167 suppressResultSets,
168 resultSetType,
169 parameterMetaData,
170 inputs);
171 }
172
173 public void readExecuteCall_() throws SqlException {
174 netAgent_.statementReply_.readExecuteCall(statement_);
175 }
176
177 public void writePrepare_(String sql, Section section) throws SqlException {
178 netAgent_.statementRequest_.writePrepare(this, sql, section);
179 }
180
181 public void readPrepare_() throws SqlException {
182 netAgent_.statementReply_.readPrepare(statement_);
183 }
184
185 public void markClosedOnServer_() {
186 }
187 }
|