1 | /* |
2 | |
3 | Derby - Class org.apache.derby.client.net.NetStatement |
4 | |
5 | Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.client.net; |
22 | |
23 | import org.apache.derby.client.am.ColumnMetaData; |
24 | import org.apache.derby.client.am.Section; |
25 | import org.apache.derby.client.am.SqlException; |
26 | import org.apache.derby.client.am.Statement; |
27 | import org.apache.derby.jdbc.ClientDriver; |
28 | |
29 | public class NetStatement implements org.apache.derby.client.am.MaterialStatement { |
30 | |
31 | Statement statement_; |
32 | |
33 | |
34 | // Alias for (NetConnection) statement_.connection |
35 | NetConnection netConnection_; |
36 | |
37 | // Alias for (NetAgent) statement_.agent |
38 | NetAgent netAgent_; |
39 | |
40 | |
41 | // If qryrowset is sent on opnqry then it also needs to be sent on every subsequent cntqry. |
42 | public boolean qryrowsetSentOnOpnqry_ = false; |
43 | |
44 | //---------------------constructors/finalizer--------------------------------- |
45 | |
46 | private NetStatement() { |
47 | initNetStatement(); |
48 | } |
49 | |
50 | private void resetNetStatement() { |
51 | initNetStatement(); |
52 | } |
53 | |
54 | private void initNetStatement() { |
55 | qryrowsetSentOnOpnqry_ = false; |
56 | } |
57 | |
58 | // Relay constructor for NetPreparedStatement. |
59 | NetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) { |
60 | this(); |
61 | initNetStatement(statement, netAgent, netConnection); |
62 | } |
63 | |
64 | void resetNetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) { |
65 | resetNetStatement(); |
66 | initNetStatement(statement, netAgent, netConnection); |
67 | } |
68 | |
69 | private void initNetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) { |
70 | netAgent_ = netAgent; |
71 | netConnection_ = netConnection; |
72 | statement_ = statement; |
73 | statement_.materialStatement_ = this; |
74 | } |
75 | |
76 | // Called by abstract Connection.createStatement().newStatement() for jdbc 1 statements |
77 | NetStatement(NetAgent netAgent, NetConnection netConnection) throws SqlException { |
78 | this(ClientDriver.getFactory().newStatement(netAgent, netConnection), |
79 | netAgent, |
80 | netConnection); |
81 | } |
82 | |
83 | void netReset(NetAgent netAgent, NetConnection netConnection) throws SqlException { |
84 | statement_.resetStatement(netAgent, netConnection); |
85 | resetNetStatement(statement_, netAgent, netConnection); |
86 | } |
87 | |
88 | public void reset_() { |
89 | qryrowsetSentOnOpnqry_ = false; |
90 | } |
91 | |
92 | // Called by abstract Connection.createStatement().newStatement() for jdbc 2 statements with scroll attributes |
93 | NetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException { |
94 | this(ClientDriver.getFactory().newStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null), |
95 | netAgent, |
96 | netConnection); |
97 | } |
98 | |
99 | void resetNetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException { |
100 | statement_.resetStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null); |
101 | resetNetStatement(statement_, netAgent, netConnection); |
102 | } |
103 | |
104 | protected void finalize() throws java.lang.Throwable { |
105 | super.finalize(); |
106 | } |
107 | |
108 | // ------------------------abstract box car methods----------------------------------------------- |
109 | |
110 | public void writeSetSpecialRegister_(java.util.ArrayList sqlsttList) throws SqlException { |
111 | netAgent_.statementRequest_.writeSetSpecialRegister(sqlsttList); |
112 | } |
113 | |
114 | public void readSetSpecialRegister_() throws SqlException { |
115 | netAgent_.statementReply_.readSetSpecialRegister(statement_); |
116 | } |
117 | |
118 | public void writeExecuteImmediate_(String sql, |
119 | Section section) throws SqlException { |
120 | netAgent_.statementRequest_.writeExecuteImmediate(this, sql, section); |
121 | } |
122 | |
123 | public void readExecuteImmediate_() throws SqlException { |
124 | netAgent_.statementReply_.readExecuteImmediate(statement_); |
125 | } |
126 | |
127 | // NOTE: NET processing does not require parameters supplied on the "read-side" so parameter sql is ignored. |
128 | public void readExecuteImmediateForBatch_(String sql) throws SqlException { |
129 | readExecuteImmediate_(); |
130 | } |
131 | |
132 | public void writePrepareDescribeOutput_(String sql, |
133 | Section section) throws SqlException { |
134 | netAgent_.statementRequest_.writePrepareDescribeOutput(this, sql, section); |
135 | } |
136 | |
137 | public void readPrepareDescribeOutput_() throws SqlException { |
138 | netAgent_.statementReply_.readPrepareDescribeOutput(statement_); |
139 | } |
140 | |
141 | public void writeOpenQuery_(Section section, |
142 | int fetchSize, |
143 | int resultSetType) |
144 | throws SqlException { |
145 | netAgent_.statementRequest_.writeOpenQuery(this, |
146 | section, |
147 | fetchSize, |
148 | resultSetType); |
149 | } |
150 | |
151 | public void readOpenQuery_() throws SqlException { |
152 | netAgent_.statementReply_.readOpenQuery(statement_); |
153 | } |
154 | |
155 | public void writeExecuteCall_(boolean outputExpected, |
156 | String procedureName, |
157 | Section section, |
158 | int fetchSize, |
159 | boolean suppressResultSets, |
160 | int resultSetType, |
161 | ColumnMetaData parameterMetaData, |
162 | Object[] inputs) throws SqlException { |
163 | netAgent_.statementRequest_.writeExecuteCall(this, |
164 | outputExpected, |
165 | procedureName, |
166 | section, |
167 | fetchSize, |
168 | suppressResultSets, |
169 | resultSetType, |
170 | parameterMetaData, |
171 | inputs); |
172 | } |
173 | |
174 | public void readExecuteCall_() throws SqlException { |
175 | netAgent_.statementReply_.readExecuteCall(statement_); |
176 | } |
177 | |
178 | public void writePrepare_(String sql, Section section) throws SqlException { |
179 | netAgent_.statementRequest_.writePrepare(this, sql, section); |
180 | } |
181 | |
182 | public void readPrepare_() throws SqlException { |
183 | netAgent_.statementReply_.readPrepare(statement_); |
184 | } |
185 | |
186 | public void markClosedOnServer_() { |
187 | } |
188 | } |