Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java @ 130:e4eacd613356
Implementierung Datenzugriff auf die ArcSDE über java.sql. Methodiken
ChangeLog wird nachgereicht da SubversionClientincompatiblitäten vorhanden sind.
geo-backend/trunk@7 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 02 Sep 2009 15:15:52 +0000 |
parents | |
children | 122fdc9da5f0 |
comparison
equal
deleted
inserted
replaced
129:110e3ac1b7d2 | 130:e4eacd613356 |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package de.intevation.gnv.geobackend.sde.datasources; | |
5 | |
6 import java.sql.Connection; | |
7 import java.sql.ResultSet; | |
8 import java.sql.SQLException; | |
9 import java.sql.SQLWarning; | |
10 import java.sql.Statement; | |
11 | |
12 import org.apache.log4j.Logger; | |
13 | |
14 import com.esri.sde.sdk.client.SeColumnDefinition; | |
15 import com.esri.sde.sdk.client.SeConnection; | |
16 import com.esri.sde.sdk.client.SeException; | |
17 import com.esri.sde.sdk.client.SeQuery; | |
18 import com.esri.sde.sdk.client.SeRow; | |
19 | |
20 /** | |
21 * @author Tim Englich <tim.englich@intevation.de> | |
22 * | |
23 */ | |
24 public class ArcSDEStatement implements Statement { | |
25 | |
26 /** | |
27 * the logger, used to log exceptions and additonaly information | |
28 */ | |
29 private static Logger log = Logger.getLogger(ArcSDEStatement.class); | |
30 | |
31 private ArcSDEConnection connection = null; | |
32 | |
33 /** | |
34 * Constructor | |
35 */ | |
36 public ArcSDEStatement(ArcSDEConnection connection) { | |
37 this.connection = connection; | |
38 } | |
39 | |
40 /** | |
41 * @see java.sql.Statement#addBatch(java.lang.String) | |
42 */ | |
43 public void addBatch(String arg0) throws SQLException { | |
44 } | |
45 | |
46 /** | |
47 * @see java.sql.Statement#cancel() | |
48 */ | |
49 public void cancel() throws SQLException { | |
50 } | |
51 | |
52 /** | |
53 * @see java.sql.Statement#clearBatch() | |
54 */ | |
55 public void clearBatch() throws SQLException { | |
56 } | |
57 | |
58 /** | |
59 * @see java.sql.Statement#clearWarnings() | |
60 */ | |
61 public void clearWarnings() throws SQLException { | |
62 } | |
63 | |
64 /** | |
65 * @see java.sql.Statement#close() | |
66 */ | |
67 public void close() throws SQLException { | |
68 } | |
69 | |
70 /** | |
71 * @see java.sql.Statement#execute(java.lang.String) | |
72 */ | |
73 public boolean execute(String arg0) throws SQLException { | |
74 | |
75 return false; | |
76 } | |
77 | |
78 /** | |
79 * @see java.sql.Statement#execute(java.lang.String, int) | |
80 */ | |
81 public boolean execute(String arg0, int arg1) throws SQLException { | |
82 | |
83 return false; | |
84 } | |
85 | |
86 /** | |
87 * @see java.sql.Statement#execute(java.lang.String, int[]) | |
88 */ | |
89 public boolean execute(String arg0, int[] arg1) throws SQLException { | |
90 | |
91 return false; | |
92 } | |
93 | |
94 /** | |
95 * @see java.sql.Statement#execute(java.lang.String, java.lang.String[]) | |
96 */ | |
97 public boolean execute(String arg0, String[] arg1) throws SQLException { | |
98 | |
99 return false; | |
100 } | |
101 | |
102 /** | |
103 * @see java.sql.Statement#executeBatch() | |
104 */ | |
105 public int[] executeBatch() throws SQLException { | |
106 | |
107 return null; | |
108 } | |
109 | |
110 /** | |
111 * @see java.sql.Statement#executeQuery(java.lang.String) | |
112 */ | |
113 public ResultSet executeQuery(String statement) throws SQLException { | |
114 try { | |
115 SeQuery query = new SeQuery(this.connection.getSeConnection()); | |
116 query.prepareSql(statement); | |
117 query.execute(); | |
118 return this.handleResultSet(query); | |
119 } catch (SeException e) { | |
120 log.error(e,e); | |
121 throw new SQLException(e.getMessage()); | |
122 } | |
123 | |
124 | |
125 } | |
126 | |
127 /** | |
128 * @see java.sql.Statement#executeUpdate(java.lang.String) | |
129 */ | |
130 public int executeUpdate(String arg0) throws SQLException { | |
131 | |
132 return 0; | |
133 } | |
134 | |
135 /** | |
136 * @see java.sql.Statement#executeUpdate(java.lang.String, int) | |
137 */ | |
138 public int executeUpdate(String arg0, int arg1) throws SQLException { | |
139 | |
140 return 0; | |
141 } | |
142 | |
143 /** | |
144 * @see java.sql.Statement#executeUpdate(java.lang.String, int[]) | |
145 */ | |
146 public int executeUpdate(String arg0, int[] arg1) throws SQLException { | |
147 | |
148 return 0; | |
149 } | |
150 | |
151 /** | |
152 * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[]) | |
153 */ | |
154 public int executeUpdate(String arg0, String[] arg1) throws SQLException { | |
155 | |
156 return 0; | |
157 } | |
158 | |
159 /** | |
160 * @see java.sql.Statement#getConnection() | |
161 */ | |
162 public Connection getConnection() throws SQLException { | |
163 return this.connection; | |
164 } | |
165 | |
166 /** | |
167 * @see java.sql.Statement#getFetchDirection() | |
168 */ | |
169 public int getFetchDirection() throws SQLException { | |
170 | |
171 return 0; | |
172 } | |
173 | |
174 /** | |
175 * @see java.sql.Statement#getFetchSize() | |
176 */ | |
177 public int getFetchSize() throws SQLException { | |
178 | |
179 return 0; | |
180 } | |
181 | |
182 /** | |
183 * @see java.sql.Statement#getGeneratedKeys() | |
184 */ | |
185 public ResultSet getGeneratedKeys() throws SQLException { | |
186 | |
187 return null; | |
188 } | |
189 | |
190 /** | |
191 * @see java.sql.Statement#getMaxFieldSize() | |
192 */ | |
193 public int getMaxFieldSize() throws SQLException { | |
194 | |
195 return 0; | |
196 } | |
197 | |
198 /** | |
199 * @see java.sql.Statement#getMaxRows() | |
200 */ | |
201 public int getMaxRows() throws SQLException { | |
202 | |
203 return 0; | |
204 } | |
205 | |
206 /** | |
207 * @see java.sql.Statement#getMoreResults() | |
208 */ | |
209 public boolean getMoreResults() throws SQLException { | |
210 | |
211 return false; | |
212 } | |
213 | |
214 /** | |
215 * @see java.sql.Statement#getMoreResults(int) | |
216 */ | |
217 public boolean getMoreResults(int arg0) throws SQLException { | |
218 | |
219 return false; | |
220 } | |
221 | |
222 /** | |
223 * @see java.sql.Statement#getQueryTimeout() | |
224 */ | |
225 public int getQueryTimeout() throws SQLException { | |
226 | |
227 return 0; | |
228 } | |
229 | |
230 /** | |
231 * @see java.sql.Statement#getResultSet() | |
232 */ | |
233 public ResultSet getResultSet() throws SQLException { | |
234 | |
235 return null; | |
236 } | |
237 | |
238 /** | |
239 * @see java.sql.Statement#getResultSetConcurrency() | |
240 */ | |
241 public int getResultSetConcurrency() throws SQLException { | |
242 | |
243 return 0; | |
244 } | |
245 | |
246 /** | |
247 * @see java.sql.Statement#getResultSetHoldability() | |
248 */ | |
249 public int getResultSetHoldability() throws SQLException { | |
250 | |
251 return 0; | |
252 } | |
253 | |
254 /** | |
255 * @see java.sql.Statement#getResultSetType() | |
256 */ | |
257 public int getResultSetType() throws SQLException { | |
258 | |
259 return 0; | |
260 } | |
261 | |
262 /** | |
263 * @see java.sql.Statement#getUpdateCount() | |
264 */ | |
265 public int getUpdateCount() throws SQLException { | |
266 | |
267 return 0; | |
268 } | |
269 | |
270 /** | |
271 * @see java.sql.Statement#getWarnings() | |
272 */ | |
273 public SQLWarning getWarnings() throws SQLException { | |
274 | |
275 return null; | |
276 } | |
277 | |
278 /** | |
279 * @see java.sql.Statement#setCursorName(java.lang.String) | |
280 */ | |
281 public void setCursorName(String arg0) throws SQLException { | |
282 } | |
283 | |
284 /** | |
285 * @see java.sql.Statement#setEscapeProcessing(boolean) | |
286 */ | |
287 public void setEscapeProcessing(boolean arg0) throws SQLException { | |
288 } | |
289 | |
290 /** | |
291 * @see java.sql.Statement#setFetchDirection(int) | |
292 */ | |
293 public void setFetchDirection(int arg0) throws SQLException { | |
294 } | |
295 | |
296 /** | |
297 * @see java.sql.Statement#setFetchSize(int) | |
298 */ | |
299 public void setFetchSize(int arg0) throws SQLException { | |
300 } | |
301 | |
302 /** | |
303 * @see java.sql.Statement#setMaxFieldSize(int) | |
304 */ | |
305 public void setMaxFieldSize(int arg0) throws SQLException { | |
306 } | |
307 | |
308 /** | |
309 * @see java.sql.Statement#setMaxRows(int) | |
310 */ | |
311 public void setMaxRows(int arg0) throws SQLException { | |
312 } | |
313 | |
314 /** | |
315 * @see java.sql.Statement#setQueryTimeout(int) | |
316 */ | |
317 public void setQueryTimeout(int arg0) throws SQLException { | |
318 } | |
319 | |
320 /** | |
321 * Copied from de.intevation.gnv.geobackend.sde.datasources.SDEQuery | |
322 * @param pSeQuery | |
323 * @return | |
324 * @throws SeException | |
325 */ | |
326 private ResultSet handleResultSet(SeQuery pSeQuery) throws SeException { | |
327 log.debug("ArcSDEStatement,handleResultSet()"); | |
328 SDEResultSet lSet = new SDEResultSet(); | |
329 SeRow row; | |
330 int lCount; | |
331 for (lCount = 0; (row = pSeQuery.fetch()) != null; lCount++) { | |
332 // one time execution | |
333 if (lCount == 0) { | |
334 // analyze cols of result set | |
335 SeColumnDefinition[] lCols = row.getColumns(); | |
336 for (SeColumnDefinition lCol : lCols) { | |
337 lSet.addCol(new ColDefinition(lCol.getName(), lCol.getType()));// notice: esri-types have been copied into colDefinition class! | |
338 } | |
339 } | |
340 short lNumCols = row.getNumColumns(); | |
341 Row lBackingRow = new Row(lNumCols); | |
342 for (int i = 0; i < lNumCols; i++) { | |
343 lBackingRow.addObject(row.getObject(i), i); | |
344 } | |
345 lSet.addRow(lBackingRow); | |
346 } | |
347 pSeQuery.close(); | |
348 return lSet; | |
349 } | |
350 | |
351 } |