KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > client > net > NetStatement


1 /*
2
3    Derby - Class org.apache.derby.client.net.NetStatement
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20 */

21
22 package org.apache.derby.client.net;
23
24 import org.apache.derby.client.am.ColumnMetaData;
25 import org.apache.derby.client.am.Section;
26 import org.apache.derby.client.am.SqlException;
27 import org.apache.derby.client.am.Statement;
28 import org.apache.derby.jdbc.ClientDriver;
29
30 public class NetStatement implements org.apache.derby.client.am.MaterialStatement {
31
32     Statement statement_;
33
34
35     // Alias for (NetConnection) statement_.connection
36
NetConnection netConnection_;
37
38     // Alias for (NetAgent) statement_.agent
39
NetAgent netAgent_;
40
41
42     // If qryrowset is sent on opnqry then it also needs to be sent on every subsequent cntqry.
43
public boolean qryrowsetSentOnOpnqry_ = false;
44
45     //---------------------constructors/finalizer---------------------------------
46

47     private NetStatement() {
48         initNetStatement();
49     }
50
51     private void resetNetStatement() {
52         initNetStatement();
53     }
54
55     private void initNetStatement() {
56         qryrowsetSentOnOpnqry_ = false;
57     }
58
59     // Relay constructor for NetPreparedStatement.
60
NetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) {
61         this();
62         initNetStatement(statement, netAgent, netConnection);
63     }
64
65     void resetNetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) {
66         resetNetStatement();
67         initNetStatement(statement, netAgent, netConnection);
68     }
69
70     private void initNetStatement(org.apache.derby.client.am.Statement statement, NetAgent netAgent, NetConnection netConnection) {
71         netAgent_ = netAgent;
72         netConnection_ = netConnection;
73         statement_ = statement;
74         statement_.materialStatement_ = this;
75     }
76
77     // Called by abstract Connection.createStatement().newStatement() for jdbc 1 statements
78
NetStatement(NetAgent netAgent, NetConnection netConnection) throws SqlException {
79         this(ClientDriver.getFactory().newStatement(netAgent, netConnection),
80                 netAgent,
81                 netConnection);
82     }
83
84     void netReset(NetAgent netAgent, NetConnection netConnection) throws SqlException {
85         statement_.resetStatement(netAgent, netConnection);
86         resetNetStatement(statement_, netAgent, netConnection);
87     }
88
89     public void reset_() {
90         qryrowsetSentOnOpnqry_ = false;
91     }
92
93     // Called by abstract Connection.createStatement().newStatement() for jdbc 2 statements with scroll attributes
94
NetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException {
95         this(ClientDriver.getFactory().newStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null),
96                 netAgent,
97                 netConnection);
98     }
99
100     void resetNetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException {
101         statement_.resetStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null);
102         resetNetStatement(statement_, netAgent, netConnection);
103     }
104
105     protected void finalize() throws java.lang.Throwable JavaDoc {
106         super.finalize();
107     }
108
109     // ------------------------abstract box car methods-----------------------------------------------
110

111     public void writeSetSpecialRegister_(java.util.ArrayList JavaDoc sqlsttList) throws SqlException {
112         netAgent_.statementRequest_.writeSetSpecialRegister(sqlsttList);
113     }
114
115     public void readSetSpecialRegister_() throws SqlException {
116         netAgent_.statementReply_.readSetSpecialRegister(statement_);
117     }
118
119     public void writeExecuteImmediate_(String JavaDoc sql,
120                                        Section section) throws SqlException {
121         netAgent_.statementRequest_.writeExecuteImmediate(this, sql, section);
122     }
123
124     public void readExecuteImmediate_() throws SqlException {
125         netAgent_.statementReply_.readExecuteImmediate(statement_);
126     }
127
128     // NOTE: NET processing does not require parameters supplied on the "read-side" so parameter sql is ignored.
129
public void readExecuteImmediateForBatch_(String JavaDoc sql) throws SqlException {
130         readExecuteImmediate_();
131     }
132
133     public void writePrepareDescribeOutput_(String JavaDoc sql,
134                                             Section section) throws SqlException {
135         netAgent_.statementRequest_.writePrepareDescribeOutput(this, sql, section);
136     }
137
138     public void readPrepareDescribeOutput_() throws SqlException {
139         netAgent_.statementReply_.readPrepareDescribeOutput(statement_);
140     }
141
142     public void writeOpenQuery_(Section section,
143                                 int fetchSize,
144                                 int resultSetType)
145             throws SqlException {
146         netAgent_.statementRequest_.writeOpenQuery(this,
147                 section,
148                 fetchSize,
149                 resultSetType);
150     }
151
152     public void readOpenQuery_() throws SqlException {
153         netAgent_.statementReply_.readOpenQuery(statement_);
154     }
155
156     public void writeExecuteCall_(boolean outputExpected,
157                                   String JavaDoc procedureName,
158                                   Section section,
159                                   int fetchSize,
160                                   boolean suppressResultSets,
161                                   int resultSetType,
162                                   ColumnMetaData parameterMetaData,
163                                   Object JavaDoc[] inputs) throws SqlException {
164         netAgent_.statementRequest_.writeExecuteCall(this,
165                 outputExpected,
166                 procedureName,
167                 section,
168                 fetchSize,
169                 suppressResultSets,
170                 resultSetType,
171                 parameterMetaData,
172                 inputs);
173     }
174
175     public void readExecuteCall_() throws SqlException {
176         netAgent_.statementReply_.readExecuteCall(statement_);
177     }
178
179     public void writePrepare_(String JavaDoc sql, Section section) throws SqlException {
180         netAgent_.statementRequest_.writePrepare(this, sql, section);
181     }
182
183     public void readPrepare_() throws SqlException {
184         netAgent_.statementReply_.readPrepare(statement_);
185     }
186
187     public void markClosedOnServer_() {
188     }
189 }
190
Popular Tags