Improved unit tests for AveragingProgressTracker class
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / controller / md / sal / dom / xsql / jdbc / JDBCStatement.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
10
11 import java.io.InputStream;
12 import java.io.Reader;
13 import java.math.BigDecimal;
14 import java.net.URL;
15 import java.sql.Array;
16 import java.sql.Blob;
17 import java.sql.Clob;
18 import java.sql.Connection;
19 import java.sql.Date;
20 import java.sql.NClob;
21 import java.sql.ParameterMetaData;
22 import java.sql.PreparedStatement;
23 import java.sql.Ref;
24 import java.sql.ResultSet;
25 import java.sql.ResultSetMetaData;
26 import java.sql.RowId;
27 import java.sql.SQLException;
28 import java.sql.SQLWarning;
29 import java.sql.SQLXML;
30 import java.sql.Time;
31 import java.sql.Timestamp;
32 import java.util.ArrayList;
33 import java.util.Calendar;
34 import java.util.Map;
35 import java.util.concurrent.ConcurrentHashMap;
36
37 /**
38  * To be removed in Nitrogen
39  */
40 @Deprecated
41 public class JDBCStatement implements PreparedStatement {
42     private JDBCResultSet rs = null;
43     private transient JDBCConnection connection = null;
44     private static Map<Integer, JDBCResultSet> queries = new ConcurrentHashMap<>();
45     private String sql = null;
46
47     public JDBCStatement(JDBCConnection con,String _sql) {
48         this.connection = con;
49         this.sql = _sql;
50     }
51
52     public JDBCStatement(JDBCConnection con) {
53         this.connection = con;
54     }
55
56     public void setSQL(String _sql){
57         this.sql = _sql;
58     }
59
60     public JDBCStatement() {
61
62     }
63
64     public PreparedStatement getProxy() {
65         return this;
66         /*
67         return (PreparedStatement) Proxy.newProxyInstance(this.getClass()
68                 .getClassLoader(), new Class[] { PreparedStatement.class },
69                 new JDBCProxy(this));
70                 */
71     }
72
73     public static JDBCResultSet getQuery(int id) {
74         return queries.get(id);
75     }
76
77     public static JDBCResultSet removeQuery(int id) {
78         return queries.remove(id);
79     }
80
81     @Override
82     public java.sql.ResultSet executeQuery(String _sql) throws SQLException {
83         rs = new JDBCResultSet(_sql);
84         queries.put(rs.getID(), rs);
85         synchronized (rs) {
86             this.connection.send(new JDBCCommand(rs,
87                     JDBCCommand.TYPE_EXECUTE_QUERY));
88             try {
89                 rs.wait();
90             } catch (Exception err) {
91             }
92             if (rs.getError() != null) {
93                 throw ((SQLException) rs.getError());
94             }
95         }
96         return rs.getProxy();
97     }
98
99     @Override
100     public boolean execute(String _sql) throws SQLException {
101         return true;
102     }
103
104     public void addRecord(ArrayList<?> hierarchy) {
105         rs.addRecord(hierarchy);
106     }
107
108     public int size() {
109         return rs.size();
110     }
111
112     public void setFinished(boolean b) {
113         this.rs.setFinished(b);
114     }
115
116     public JDBCResultSet getRS() {
117         return this.rs;
118     }
119
120     public ResultSet getResultSet() {
121         return this.rs;
122     }
123
124     @Override
125     public boolean isWrapperFor(Class<?> arg0) throws SQLException {
126         // TODO Auto-generated method stub
127         return false;
128     }
129
130     @Override
131     public <T> T unwrap(Class<T> arg0) throws SQLException {
132         // TODO Auto-generated method stub
133         return null;
134     }
135
136     @Override
137     public void addBatch(String sql) throws SQLException {
138         // TODO Auto-generated method stub
139
140     }
141
142     @Override
143     public void cancel() throws SQLException {
144         // TODO Auto-generated method stub
145
146     }
147
148     @Override
149     public void clearBatch() throws SQLException {
150         // TODO Auto-generated method stub
151
152     }
153
154     @Override
155     public void clearWarnings() throws SQLException {
156         // TODO Auto-generated method stub
157
158     }
159
160     @Override
161     public void close() throws SQLException {
162         // TODO Auto-generated method stub
163
164     }
165
166     @Override
167     public boolean execute(String sql, int autoGeneratedKeys)
168             throws SQLException {
169         // TODO Auto-generated method stub
170         return false;
171     }
172
173     @Override
174     public boolean execute(String sql, int[] columnIndexes) throws SQLException {
175         // TODO Auto-generated method stub
176         return false;
177     }
178
179     @Override
180     public boolean execute(String sql, String[] columnNames)
181             throws SQLException {
182         // TODO Auto-generated method stub
183         return false;
184     }
185
186     @Override
187     public int[] executeBatch() throws SQLException {
188         // TODO Auto-generated method stub
189         return null;
190     }
191
192     @Override
193     public int executeUpdate(String sql, int autoGeneratedKeys)
194             throws SQLException {
195         // TODO Auto-generated method stub
196         return 0;
197     }
198
199     @Override
200     public int executeUpdate(String sql, int[] columnIndexes)
201             throws SQLException {
202         // TODO Auto-generated method stub
203         return 0;
204     }
205
206     @Override
207     public int executeUpdate(String sql, String[] columnNames)
208             throws SQLException {
209         // TODO Auto-generated method stub
210         return 0;
211     }
212
213     @Override
214     public int executeUpdate(String sql) throws SQLException {
215         // TODO Auto-generated method stub
216         return 0;
217     }
218
219     @Override
220     public Connection getConnection() throws SQLException {
221         // TODO Auto-generated method stub
222         return null;
223     }
224
225     @Override
226     public int getFetchDirection() throws SQLException {
227         // TODO Auto-generated method stub
228         return 0;
229     }
230
231     @Override
232     public int getFetchSize() throws SQLException {
233         // TODO Auto-generated method stub
234         return 0;
235     }
236
237     @Override
238     public java.sql.ResultSet getGeneratedKeys() throws SQLException {
239         // TODO Auto-generated method stub
240         return null;
241     }
242
243     @Override
244     public int getMaxFieldSize() throws SQLException {
245         // TODO Auto-generated method stub
246         return 0;
247     }
248
249     @Override
250     public int getMaxRows() throws SQLException {
251         return 200;
252     }
253
254     @Override
255     public boolean getMoreResults() throws SQLException {
256         // TODO Auto-generated method stub
257         return false;
258     }
259
260     @Override
261     public boolean getMoreResults(int current) throws SQLException {
262         // TODO Auto-generated method stub
263         return false;
264     }
265
266     @Override
267     public int getQueryTimeout() throws SQLException {
268         // TODO Auto-generated method stub
269         return 0;
270     }
271
272     @Override
273     public int getResultSetConcurrency() throws SQLException {
274         // TODO Auto-generated method stub
275         return 0;
276     }
277
278     @Override
279     public int getResultSetHoldability() throws SQLException {
280         // TODO Auto-generated method stub
281         return 0;
282     }
283
284     @Override
285     public int getResultSetType() throws SQLException {
286         // TODO Auto-generated method stub
287         return 0;
288     }
289
290     @Override
291     public int getUpdateCount() throws SQLException {
292         // TODO Auto-generated method stub
293         return 0;
294     }
295
296     @Override
297     public SQLWarning getWarnings() throws SQLException {
298         // TODO Auto-generated method stub
299         return null;
300     }
301
302     @Override
303     public boolean isClosed() throws SQLException {
304         // TODO Auto-generated method stub
305         return false;
306     }
307
308     @Override
309     public boolean isPoolable() throws SQLException {
310         // TODO Auto-generated method stub
311         return false;
312     }
313
314     @Override
315     public void setCursorName(String name) throws SQLException {
316         // TODO Auto-generated method stub
317
318     }
319
320     @Override
321     public void setEscapeProcessing(boolean enable) throws SQLException {
322         // TODO Auto-generated method stub
323
324     }
325
326     @Override
327     public void setFetchDirection(int direction) throws SQLException {
328         // TODO Auto-generated method stub
329
330     }
331
332     @Override
333     public void setFetchSize(int rows) throws SQLException {
334         // TODO Auto-generated method stub
335
336     }
337
338     @Override
339     public void setMaxFieldSize(int max) throws SQLException {
340         // TODO Auto-generated method stub
341
342     }
343
344     @Override
345     public void setMaxRows(int max) throws SQLException {
346         // TODO Auto-generated method stub
347
348     }
349
350     @Override
351     public void setPoolable(boolean poolable) throws SQLException {
352         // TODO Auto-generated method stub
353
354     }
355
356     @Override
357     public void setQueryTimeout(int seconds) throws SQLException {
358         // TODO Auto-generated method stub
359
360     }
361
362     @Override
363     public void closeOnCompletion() throws SQLException {
364         // TODO Auto-generated method stub
365
366     }
367
368     @Override
369     public boolean isCloseOnCompletion() throws SQLException {
370         // TODO Auto-generated method stub
371         return false;
372     }
373
374     @Override
375     public ResultSet executeQuery() throws SQLException {
376         return this.executeQuery(this.sql);
377     }
378
379     @Override
380     public int executeUpdate() throws SQLException {
381         // TODO Auto-generated method stub
382         return 0;
383     }
384
385     @Override
386     public void setNull(int parameterIndex, int sqlType) throws SQLException {
387         // TODO Auto-generated method stub
388
389     }
390
391     @Override
392     public void setBoolean(int parameterIndex, boolean x) throws SQLException {
393         // TODO Auto-generated method stub
394
395     }
396
397     @Override
398     public void setByte(int parameterIndex, byte x) throws SQLException {
399         // TODO Auto-generated method stub
400
401     }
402
403     @Override
404     public void setShort(int parameterIndex, short x) throws SQLException {
405         // TODO Auto-generated method stub
406
407     }
408
409     @Override
410     public void setInt(int parameterIndex, int x) throws SQLException {
411         // TODO Auto-generated method stub
412
413     }
414
415     @Override
416     public void setLong(int parameterIndex, long x) throws SQLException {
417         // TODO Auto-generated method stub
418
419     }
420
421     @Override
422     public void setFloat(int parameterIndex, float x) throws SQLException {
423         // TODO Auto-generated method stub
424
425     }
426
427     @Override
428     public void setDouble(int parameterIndex, double x) throws SQLException {
429         // TODO Auto-generated method stub
430
431     }
432
433     @Override
434     public void setBigDecimal(int parameterIndex, BigDecimal x)
435             throws SQLException {
436         // TODO Auto-generated method stub
437
438     }
439
440     @Override
441     public void setString(int parameterIndex, String x) throws SQLException {
442         // TODO Auto-generated method stub
443
444     }
445
446     @Override
447     public void setBytes(int parameterIndex, byte[] x) throws SQLException {
448         // TODO Auto-generated method stub
449
450     }
451
452     @Override
453     public void setDate(int parameterIndex, Date x) throws SQLException {
454         // TODO Auto-generated method stub
455
456     }
457
458     @Override
459     public void setTime(int parameterIndex, Time x) throws SQLException {
460         // TODO Auto-generated method stub
461
462     }
463
464     @Override
465     public void setTimestamp(int parameterIndex, Timestamp x)
466             throws SQLException {
467         // TODO Auto-generated method stub
468
469     }
470
471     @Override
472     public void setAsciiStream(int parameterIndex, InputStream x, int length)
473             throws SQLException {
474         // TODO Auto-generated method stub
475
476     }
477
478     @Override
479     public void setUnicodeStream(int parameterIndex, InputStream x, int length)
480             throws SQLException {
481         // TODO Auto-generated method stub
482
483     }
484
485     @Override
486     public void setBinaryStream(int parameterIndex, InputStream x, int length)
487             throws SQLException {
488         // TODO Auto-generated method stub
489
490     }
491
492     @Override
493     public void clearParameters() throws SQLException {
494         // TODO Auto-generated method stub
495
496     }
497
498     @Override
499     public void setObject(int parameterIndex, Object x, int targetSqlType)
500             throws SQLException {
501         // TODO Auto-generated method stub
502
503     }
504
505     @Override
506     public void setObject(int parameterIndex, Object x) throws SQLException {
507         // TODO Auto-generated method stub
508     }
509
510     @Override
511     public boolean execute() throws SQLException {
512         // TODO Auto-generated method stub
513         return false;
514     }
515
516     @Override
517     public void addBatch() throws SQLException {
518         // TODO Auto-generated method stub
519
520     }
521
522     @Override
523     public void setCharacterStream(int parameterIndex, Reader reader, int length)
524             throws SQLException {
525         // TODO Auto-generated method stub
526
527     }
528
529     @Override
530     public void setRef(int parameterIndex, Ref x) throws SQLException {
531         // TODO Auto-generated method stub
532
533     }
534
535     @Override
536     public void setBlob(int parameterIndex, Blob x) throws SQLException {
537         // TODO Auto-generated method stub
538
539     }
540
541     @Override
542     public void setClob(int parameterIndex, Clob x) throws SQLException {
543         // TODO Auto-generated method stub
544
545     }
546
547     @Override
548     public void setArray(int parameterIndex, Array x) throws SQLException {
549         // TODO Auto-generated method stub
550
551     }
552
553     @Override
554     public ResultSetMetaData getMetaData() throws SQLException {
555         // TODO Auto-generated method stub
556         return null;
557     }
558
559     @Override
560     public void setDate(int parameterIndex, Date x, Calendar cal)
561             throws SQLException {
562         // TODO Auto-generated method stub
563
564     }
565
566     @Override
567     public void setTime(int parameterIndex, Time x, Calendar cal)
568             throws SQLException {
569         // TODO Auto-generated method stub
570
571     }
572
573     @Override
574     public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
575             throws SQLException {
576         // TODO Auto-generated method stub
577
578     }
579
580     @Override
581     public void setNull(int parameterIndex, int sqlType, String typeName)
582             throws SQLException {
583         // TODO Auto-generated method stub
584
585     }
586
587     @Override
588     public void setURL(int parameterIndex, URL x) throws SQLException {
589         // TODO Auto-generated method stub
590
591     }
592
593     @Override
594     public ParameterMetaData getParameterMetaData() throws SQLException {
595         // TODO Auto-generated method stub
596         return null;
597     }
598
599     @Override
600     public void setRowId(int parameterIndex, RowId x) throws SQLException {
601         // TODO Auto-generated method stub
602
603     }
604
605     @Override
606     public void setNString(int parameterIndex, String value)
607             throws SQLException {
608         // TODO Auto-generated method stub
609
610     }
611
612     @Override
613     public void setNCharacterStream(int parameterIndex, Reader value,
614             long length) throws SQLException {
615         // TODO Auto-generated method stub
616
617     }
618
619     @Override
620     public void setNClob(int parameterIndex, NClob value) throws SQLException {
621         // TODO Auto-generated method stub
622
623     }
624
625     @Override
626     public void setClob(int parameterIndex, Reader reader, long length)
627             throws SQLException {
628         // TODO Auto-generated method stub
629
630     }
631
632     @Override
633     public void setBlob(int parameterIndex, InputStream inputStream, long length)
634             throws SQLException {
635         // TODO Auto-generated method stub
636
637     }
638
639     @Override
640     public void setNClob(int parameterIndex, Reader reader, long length)
641             throws SQLException {
642         // TODO Auto-generated method stub
643
644     }
645
646     @Override
647     public void setSQLXML(int parameterIndex, SQLXML xmlObject)
648             throws SQLException {
649         // TODO Auto-generated method stub
650
651     }
652
653     @Override
654     public void setObject(int parameterIndex, Object x, int targetSqlType,
655             int scaleOrLength) throws SQLException {
656         // TODO Auto-generated method stub
657
658     }
659
660     @Override
661     public void setAsciiStream(int parameterIndex, InputStream x, long length)
662             throws SQLException {
663         // TODO Auto-generated method stub
664
665     }
666
667     @Override
668     public void setBinaryStream(int parameterIndex, InputStream x, long length)
669             throws SQLException {
670         // TODO Auto-generated method stub
671
672     }
673
674     @Override
675     public void setCharacterStream(int parameterIndex, Reader reader,
676             long length) throws SQLException {
677         // TODO Auto-generated method stub
678
679     }
680
681     @Override
682     public void setAsciiStream(int parameterIndex, InputStream x)
683             throws SQLException {
684         // TODO Auto-generated method stub
685
686     }
687
688     @Override
689     public void setBinaryStream(int parameterIndex, InputStream x)
690             throws SQLException {
691         // TODO Auto-generated method stub
692
693     }
694
695     @Override
696     public void setCharacterStream(int parameterIndex, Reader reader)
697             throws SQLException {
698         // TODO Auto-generated method stub
699
700     }
701
702     @Override
703     public void setNCharacterStream(int parameterIndex, Reader value)
704             throws SQLException {
705         // TODO Auto-generated method stub
706
707     }
708
709     @Override
710     public void setClob(int parameterIndex, Reader reader) throws SQLException {
711         // TODO Auto-generated method stub
712
713     }
714
715     @Override
716     public void setBlob(int parameterIndex, InputStream inputStream)
717             throws SQLException {
718         // TODO Auto-generated method stub
719
720     }
721
722     @Override
723     public void setNClob(int parameterIndex, Reader reader) throws SQLException {
724         // TODO Auto-generated method stub
725
726     }
727
728 }