• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package tests.sql;
18 
19 import dalvik.annotation.KnownFailure;
20 import dalvik.annotation.TestTargets;
21 import dalvik.annotation.TestLevel;
22 import dalvik.annotation.TestTargetNew;
23 import dalvik.annotation.TestTargetClass;
24 
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.io.InputStreamReader;
28 import java.io.OutputStream;
29 import java.io.Reader;
30 import java.io.Writer;
31 import java.math.BigDecimal;
32 import java.net.URL;
33 import java.sql.Array;
34 import java.sql.Blob;
35 import java.sql.Clob;
36 import java.sql.Date;
37 import java.sql.ParameterMetaData;
38 import java.sql.PreparedStatement;
39 import java.sql.Ref;
40 import java.sql.ResultSet;
41 import java.sql.ResultSetMetaData;
42 import java.sql.SQLException;
43 import java.sql.Statement;
44 import java.sql.Time;
45 import java.sql.Timestamp;
46 import java.sql.Types;
47 import java.text.SimpleDateFormat;
48 import java.util.Calendar;
49 import java.util.GregorianCalendar;
50 import java.util.Locale;
51 import java.util.Map;
52 import java.util.TimeZone;
53 
54 @TestTargetClass(PreparedStatement.class)
55 public class PreparedStatementTest extends SQLTest {
56 
57     String queryAllSelect = "select * from type";
58 
59     String[] queries = {
60             "create table type (" +
61 
62             " BoolVal BOOLEAN," + " IntVal INT," + " LongVal LONG,"
63                     + " Bint BIGINT," + " Tint TINYINT," + " Sint SMALLINT,"
64                     + " Mint MEDIUMINT, " +
65 
66                     " IntegerVal INTEGER, " + " RealVal REAL, "
67                     + " DoubleVal DOUBLE, " + " FloatVal FLOAT, "
68                     + " DecVal DECIMAL, " +
69 
70                     " NumVal NUMERIC, " + " charStr CHAR(20), "
71                     + " dateVal DATE, " + " timeVal TIME, " + " TS TIMESTAMP, "
72                     +
73 
74                     " DT DATETIME, " + " TBlob TINYBLOB, " + " BlobVal BLOB, "
75                     + " MBlob MEDIUMBLOB, " + " LBlob LONGBLOB, " +
76 
77                     " TText TINYTEXT, " + " TextVal TEXT, "
78                     + " MText MEDIUMTEXT, " + " LText LONGTEXT " + ");",
79 
80             "insert into type (BoolVal, IntVal, LongVal, Bint, Tint, Sint, Mint,"
81                     + "IntegerVal, RealVal, DoubleVal, FloatVal, DecVal,"
82                     + "NumVal, charStr, dateVal, timeVal, TS,"
83                     + "DT, TBlob, BlobVal, MBlob, LBlob,"
84                     + "TText, TextVal, MText, LText"
85                     + ") "
86                     + "values (1, -1, 22, 2, 33,"
87                     + "3, 1, 2, 3.9, 23.2, 33.3, 44,"
88                     + "5, 'test string', '1799-05-26', '12:35:45', '2007-10-09 14:28:02.0',"
89                     + "'1221-09-22 10:11:55', 1, 2, 3, 4,"
90                     + "'Test text message tiny', 'Test text message', 'Test text message medium', 'Test text message long');" };
91 
setUp()92     public void setUp() throws Exception {
93         super.setUp();
94         Statement st = null;
95         try {
96             st = conn.createStatement();
97             for (int i = 0; i < queries.length; i++) {
98                 st.execute(queries[i]);
99             }
100         } catch (SQLException e) {
101             fail("SQLException is thrown: " + e.toString());
102         } finally {
103             try {
104                 st.close();
105             } catch (Exception ee) {
106             }
107         }
108     }
109 
tearDown()110     public void tearDown() {
111         Statement st = null;
112         try {
113             st = conn.createStatement();
114             st.execute("drop table if exists type");
115         } catch (SQLException e) {
116             fail("SQLException is thrown");
117         } finally {
118             try {
119                 st.close();
120             } catch (SQLException ee) {
121             }
122         }
123         super.tearDown();
124     }
125 
126     /**
127      * @test java.sql.PreparedStatement#addBatch()
128      */
129     @TestTargetNew(
130         level = TestLevel.COMPLETE,
131         notes = "",
132         method = "addBatch",
133         args = {}
134     )
testAddBatch()135     public void testAddBatch() throws SQLException {
136         PreparedStatement ps = null;
137         try {
138             ps = conn
139                     .prepareStatement("INSERT INTO zoo VALUES (3,'Tuzik', ?);");
140             ps.addBatch("INSERT INTO zoo VALUES (?,'Burenka', ?); ");
141             ps.addBatch("INSERT INTO zoo VALUES (?,'Mashka','cat')");
142             try {
143                 ps.executeBatch();
144             } catch (SQLException sqle) {
145                 fail("SQLException is thrown for executeBatch()");
146             }
147             ps.setString(1, "dog");
148             Statement st = null;
149             try {
150                 ps.executeBatch();
151                 st = conn.createStatement();
152                 st.execute("select * from zoo");
153                 ResultSet rs = st.getResultSet();
154                 assertEquals(2, getCount(rs));
155             } catch (SQLException sqle) {
156                 fail("SQLException is thrown for executeBatch()");
157             } finally {
158                 try {
159                     st.close();
160                 } catch (SQLException ee) {
161                 }
162             }
163         } catch (SQLException e) {
164             fail("SQLException is thrown "+e.getMessage());
165         } finally {
166             try {
167                 ps.close();
168             } catch (SQLException ee) {
169             }
170         }
171 
172         try {
173             ps = conn
174                     .prepareStatement("INSERT INTO zoo VALUES (3,'Tuzik', ?);");
175             ps.addBatch("");
176         } catch (SQLException e) {
177             // expected
178         } finally {
179             try {
180                 ps.close();
181             } catch (SQLException ee) {
182             }
183         }
184 
185         try {
186             ps = conn
187                     .prepareStatement("INSERT INTO zoo VALUES (3,'Tuzik', ?);");
188             ps.addBatch(null);
189         } catch (SQLException e) {
190             // expected
191         } finally {
192             try {
193                 ps.close();
194             } catch (SQLException ee) {
195             }
196         }
197     }
198 
199 
200     /**
201      * @test java.sql.PreparedStatement#execute()
202      */
203     @TestTargetNew(
204         level = TestLevel.COMPLETE,
205         notes = "",
206         method = "execute",
207         args = {}
208     )
209     @KnownFailure("preparedStatement.execute() does not return false on update.")
testExecute()210     public void testExecute() {
211         Statement st = null;
212         PreparedStatement ps = null;
213         try {
214             //update
215             String query = "insert into zoo(id, family, name) values(?, ?, 'unknown animal')";
216             ps = conn.prepareStatement(query);
217             ps.setInt(1, 3);
218             ps.setString(2, "No name");
219             assertFalse(ps.execute());
220             assertEquals(1,ps.getUpdateCount());
221 
222             // select
223             ps = conn.prepareStatement("select * from zoo");
224             assertTrue(ps.execute());
225             assertEquals(3, getCount(ps.getResultSet()));
226         } catch (SQLException e) {
227             fail("SQLException is thrown: " + e.getMessage());
228         } finally {
229             try {
230                 ps.close();
231             } catch (Exception ee) {
232             }
233         }
234 
235         try {
236             String query = "update zoo set name='Masha', family=? where id=?;";
237             ps = conn.prepareStatement(query);
238             ps.setString(1, "cat");
239             ps.setInt(2, 2);
240             assertFalse(ps.execute());
241             assertEquals(1, ps.getUpdateCount());
242             st = conn.createStatement();
243             st.execute("select family from zoo where id=2");
244             ResultSet rs = st.getResultSet();
245             rs.next();
246             assertEquals("cat", rs.getString(1));
247         } catch (SQLException e) {
248             fail("SQLException is thrown: " + e.getMessage());
249         } finally {
250             try {
251                 ps.close();
252                 st.close();
253             } catch (Exception ee) {
254             }
255         }
256 
257         try {
258             conn.createStatement().execute("drop table if exists hutch");
259             String query = "create table hutch (id integer not null, animal_id integer, address char(20), primary key (id));";
260             ps = conn.prepareStatement(query);
261             assertFalse(ps.execute());
262             assertTrue(ps.getUpdateCount() > 0);
263         } catch (SQLException e) {
264             fail("SQLException is thrown: " + e.getMessage());
265         } finally {
266             try {
267                 ps.close();
268             } catch (Exception ee) {
269             }
270         }
271 
272         try {
273             String query = "select name, family from zoo where id = ?";
274             ps = conn.prepareStatement(query);
275             ps.setInt(1, 1);
276             assertTrue(ps.execute());
277         } catch (SQLException e) {
278             fail("SQLException is thrown: " + e.getMessage());
279         } finally {
280             try {
281                 ps.close();
282             } catch (Exception ee) {
283             }
284         }
285 
286         try {
287             String query = "select name, family from zoo where id = ?";
288             ps = conn.prepareStatement(query);
289             ps.execute();
290         } catch (SQLException e) {
291             fail("SQLException is thrown");
292         } finally {
293             try {
294                 ps.close();
295             } catch (Exception ee) {
296             }
297         }
298         //Exception test
299         try {
300             String query = "update zoo set name='Masha', family=? where id=?;";
301             ps = conn.prepareStatement(query);
302             ps.setString(1, "cat");
303             ps.setInt(2, 2);
304             assertTrue(ps.execute("update zoo set name='Masha', family='cat' where id=2;"));
305         } catch (SQLException e) {
306             // ok Should not provide string argument for a prepared Statement
307         } finally {
308             try {
309                 ps.close();
310             } catch (Exception ee) {
311             }
312         }
313     }
314 
315 
316     /**
317      * @test java.sql.PreparedStatement#executeQuery()
318      */
319     @TestTargetNew(
320         level = TestLevel.COMPLETE,
321         notes = "",
322         method = "executeQuery",
323         args = {}
324     )
testExecuteQuery()325       public void testExecuteQuery() {
326 
327         String[] queries2 = {
328                 "update zoo set name='Masha', family='cat' where id=;",
329                 "insert into hutch (id, animal_id, address) values (1, ?,'Birds-house, 1');",
330                 "insert into hutch (id, animal_id, address) values (?, 1, 'Horse-house, 5');",
331                 "create view address as select address from hutch where animal_id=?"};
332 
333         for (int i = 0; i < queries2.length; i++) {
334             PreparedStatement ps = null;
335             try {
336                 ps = conn.prepareStatement(queries2[i]);
337                 ps.executeQuery();
338                 fail("SQLException is not thrown for query: " + queries2[i]);
339             } catch (SQLException sqle) {
340                 // expected
341             } finally {
342                 try {
343                     ps.close();
344                 } catch (Exception ee) {
345                 }
346             }
347         }
348 
349         String query = "select * from zoo where id = ?";
350         PreparedStatement ps = null;
351         try {
352             ps = conn.prepareStatement(query);
353             ps.setInt(1, 1);
354             ResultSet rs = ps.executeQuery();
355             rs.next();
356             assertEquals(1, rs.getInt(1));
357             assertEquals("Kesha", rs.getString(2));
358             assertEquals("parrot", rs.getString(3));
359         } catch (SQLException e) {
360             fail("SQLException is thrown for query");
361         } finally {
362             try {
363                 ps.close();
364             } catch (Exception ee) {
365             }
366         }
367 
368         try {
369             ps = conn.prepareStatement(query);
370             ps.setInt(1, 5);
371             ResultSet rs = ps.executeQuery();
372             assertNotNull(rs);
373             assertFalse(rs.next());
374         } catch (SQLException e) {
375             fail("SQLException is thrown for query");
376         } finally {
377             try {
378                 ps.close();
379             } catch (Exception ee) {
380             }
381         }
382     }
383 
384      // TODO Crashes VM. Fix later.
385     /**
386      * @test {@link java.sql.PreparedStatement#executeUpdate()}
387      */
388     @TestTargetNew(
389         level = TestLevel.COMPLETE,
390         notes = "",
391         method = "executeUpdate",
392         args = {}
393     )
testExecuteUpdate()394       public void testExecuteUpdate() {
395           String[] queries1 = { "insert into hutch (id, animal_id, address) values (1, ?, 'Birds-house, 1');",
396                               "insert into hutch (id, animal_id, address) values (?, 1, 'Horse-house, 5');",
397                               "create view address as select address from hutch where animal_id=2" };
398 
399           for (int i = 0; i < queries1.length; i++) {
400               PreparedStatement ps = null;
401               try {
402                   ps = conn.prepareStatement(queries1[i]);
403                   ps.executeUpdate();
404                   fail("SQLException is not thrown for query: " + queries1[i]);
405           } catch(SQLException sqle) {
406               // expected
407           } finally {
408               try {
409                   ps.close();
410               } catch(Exception ee) {}
411           }
412       }
413 
414           String query = "update zoo set name='Masha', family='cat' where id=?;";
415           PreparedStatement ps = null;
416           try {
417               ps = conn.prepareStatement(query);
418               ps.setInt(1, 2);
419               int updateCount = ps.executeUpdate();
420               assertEquals(1, updateCount);
421               ps.setInt(1, 1);
422               int updateCount1 = ps.executeUpdate();
423               assertEquals(1, updateCount1);
424           } catch (SQLException e) {
425               fail("SQLException is thrown for query");
426           } finally {
427               try {
428                   ps.close();
429               } catch(Exception ee) {}
430           }
431       }
432 
433     /**
434      * @test java.sql.PreparedStatement#getMetaData()
435      *
436      *  Test Fails:
437      * TODO Doesn't pass. according to Java docs:
438      * it is possible to invoke the method getMetaData on a
439      * PreparedStatement object before it is executed.
440      */
441     @TestTargetNew(
442         level = TestLevel.COMPLETE,
443         notes = "",
444         method = "getMetaData",
445         args = {}
446     )
447     @KnownFailure("it is not possible to invoke the method getMetaData on a " +
448                   "PreparedStatement object before it is executed: got NullPointerException."+
449                   "Test passes on RI.")
testGetMetaData()450     public void testGetMetaData() {
451         PreparedStatement ps = null;
452 
453         // Specification testing
454 
455         try {
456             String query = "update zoo set name='Masha', family='cat' where id=?;";
457             ps = conn.prepareStatement(query);
458             assertNotNull(ps);
459             ResultSetMetaData meta = ps.getMetaData();
460             assertNotNull(meta);
461         } catch (SQLException sqle) {
462             fail("SQLException is thrown: " + sqle.toString());
463             sqle.printStackTrace();
464         } catch (Exception e) {
465             fail("Unspecified Exception: " + e.toString());
466             e.printStackTrace();
467         } finally {
468             try {
469                 ps.close();
470             } catch (SQLException ee) {
471             }
472         }
473 
474         try {
475             String query = "select * from zoo where id = ?";
476             ps = conn.prepareStatement(query);
477             ResultSetMetaData rsmd = ps.getMetaData();
478             assertNotNull(rsmd);
479             assertEquals(3, rsmd.getColumnCount());
480             assertEquals("id", rsmd.getColumnName(1));
481         } catch (SQLException e) {
482             fail("SQLException is thrown");
483         } finally {
484             try {
485                 ps.close();
486             } catch (SQLException ee) {
487             }
488         }
489 
490         // ps closed
491         try {
492             ps.getMetaData();
493             fail("SQLException expected");
494         } catch (SQLException e) {
495             // ok
496         }
497     }
498 
499     /**
500      * @throws SQLException
501      * @test java.sql.PreparedStatement#getParameterMetaData()
502      */
503     @TestTargetNew(
504         level = TestLevel.NOT_FEASIBLE,
505         notes = "not supported",
506         method = "getParameterMetaData",
507         args = {}
508     )
testGetParameterMetaData()509     public void testGetParameterMetaData() throws SQLException {
510         PreparedStatement ps = null;
511         String query = "select * from zoo where id = ?";
512         ps = conn.prepareStatement(query);
513 
514         try {
515             ParameterMetaData rsmd = ps.getParameterMetaData();
516         } catch (SQLException e) {
517             assertEquals("not supported",e.getMessage());
518         } finally {
519             try {
520                 ps.close();
521             } catch (SQLException ee) {
522             }
523         }
524 
525         ps.close();
526 
527         try {
528             ps.getParameterMetaData();
529             fail("SQLException expected");
530         } catch (SQLException e) {
531             // ok
532         }
533     }
534 
535 
536     /**
537      * @test java.sql.PreparedStatement#clearParameters()
538      * Test fails: clearparameters should be implemented with Stmt.reset()
539      */
540     @TestTargetNew(
541         level = TestLevel.COMPLETE,
542         notes = "Test fails: clearparameters should be implemented with Stmt.reset()",
543         method = "clearParameters",
544         args = {}
545     )
546     @KnownFailure("First Exception test fails: parameters not cleared.")
testClearParameters()547      public void testClearParameters() {
548         PreparedStatement ps = null;
549         try {
550             String query = "select * from zoo where id = ? and family=?";
551             ps = conn.prepareStatement(query);
552             ps.clearParameters();
553             try {
554                 ps.execute();
555                 fail("SQLException is not thrown during execute method after calling clearParameters()");
556             } catch (SQLException sql) {
557 
558             }
559             ps.setInt(1, 2);
560             ps.setString(2, "dog");
561             ps.clearParameters();
562             try {
563                 ps.execute();
564                 fail("SQLException is not thrown during execute method after calling clearParameters()");
565             } catch (SQLException sqle) {
566                 // expected
567             }
568             ps.setInt(1, 2);
569             ps.clearParameters();
570             try {
571                 ps.execute();
572                 fail("SQLException is not thrown during execute method after calling clearParameters()");
573             } catch (SQLException sqle) {
574                 // expected
575             }
576             ps.setInt(1, 2);
577             ps.setString(2, "cat");
578 
579             try {
580                 ps.execute();
581             } catch (SQLException sqle) {
582                 fail("SQLException is thrown during execute method after calling clearParameters() twice");
583             }
584         } catch (SQLException e) {
585             fail("SQLException is thrown");
586         } finally {
587             try {
588                 ps.close();
589             } catch (SQLException ee) {
590             }
591         }
592 
593     }
594 
595     /**
596      * @test java.sql.PreparedStatement#setInt(int parameterIndex, int x)
597      */
598     @TestTargetNew(
599         level = TestLevel.COMPLETE,
600         notes = "",
601         method = "setInt",
602         args = {int.class, int.class}
603     )
604     @KnownFailure("exception test fails")
testSetInt()605     public void testSetInt() throws SQLException {
606 
607         PreparedStatement ps = null;
608         Statement st = null;
609         try {
610             String query = "insert into type (IntVal) values (?);";
611             ps = conn.prepareStatement(query);
612             try {
613                 ps.setInt(1, Integer.MAX_VALUE);
614                 ps.execute();
615                 st = conn.createStatement();
616                 st.execute("select * from type where IntVal="
617                         + Integer.MAX_VALUE);
618                 ResultSet rs = st.getResultSet();
619                 assertEquals(1, getCount(rs));
620             } catch (SQLException sqle) {
621                 fail("SQLException is thrown: " + sqle.getMessage());
622             } finally {
623                 try {
624                     ps.close();
625                     st.close();
626                 } catch (Exception ee) {
627                 }
628             }
629             ps = conn.prepareStatement(query);
630             try {
631                 ps.setInt(1, Integer.MIN_VALUE);
632                 ps.execute();
633                 st = conn.createStatement();
634                 st.execute("select * from type where IntVal="
635                         + Integer.MAX_VALUE);
636                 ResultSet rs = st.getResultSet();
637                 assertEquals(1, getCount(rs));
638             } catch (SQLException sqle) {
639                 fail("SQLException is thrown: " + sqle.getMessage());
640             } finally {
641                 try {
642                     ps.close();
643                     st.close();
644                 } catch (SQLException ee) {
645                 }
646             }
647             ps = conn.prepareStatement(query);
648             ps.close();
649             try {
650                 ps.setInt(1, Integer.MIN_VALUE);
651                 fail("SQLException is not thrown");
652             } catch (SQLException sqle) {
653                 // expected
654             }
655 
656         } catch (SQLException e) {
657             fail("SQLException is thrown: " + e.getMessage());
658         } finally {
659             try {
660 
661                 ps.close();
662             } catch (SQLException ee) {
663             }
664         }
665     }
666 
667     /**
668      * @test java.sql.PreparedStatement#setLong(int parameterIndex, long x)
669      */
670     @TestTargetNew(
671         level = TestLevel.COMPLETE,
672         notes = "",
673         method = "setLong",
674         args = {int.class, long.class}
675     )
676     @KnownFailure("exception test fails")
testSetLong()677     public void testSetLong() {
678 
679         PreparedStatement ps = null;
680         try {
681             String query = "insert into type (LongVal) values (?);";
682             ps = conn.prepareStatement(query);
683             Statement st = null;
684             try {
685                 ps.setLong(1, Long.MAX_VALUE);
686                 ps.execute();
687                 st = conn.createStatement();
688                 st
689                         .execute("select * from type where LongVal="
690                                 + Long.MAX_VALUE);
691                 ResultSet rs = st.getResultSet();
692                 assertEquals(1, getCount(rs));
693             } catch (SQLException sqle) {
694                 fail("SQLException is thrown: " + sqle.getMessage());
695             } finally {
696                 try {
697                     st.close();
698                 } catch (Exception ee) {
699                 }
700             }
701 
702             try {
703                 ps.setLong(1, Long.MIN_VALUE);
704                 ps.execute();
705                 st = conn.createStatement();
706                 st
707                         .execute("select * from type where LongVal="
708                                 + Long.MAX_VALUE);
709                 ResultSet rs = st.getResultSet();
710                 assertEquals(1, getCount(rs));
711             } catch (SQLException sqle) {
712                 fail("SQLException is thrown: " + sqle.getMessage());
713             } finally {
714                 try {
715                     st.close();
716                 } catch (SQLException ee) {
717                 }
718             }
719 
720             ps.close();
721             try {
722                 ps.setLong(1, Long.MIN_VALUE);
723                 fail("SQLException is not thrown");
724             } catch (SQLException sqle) {
725                 // expected
726             }
727 
728         } catch (SQLException e) {
729             fail("SQLException is thrown: " + e.getMessage());
730         } finally {
731             try {
732 
733                 ps.close();
734             } catch (SQLException ee) {
735             }
736         }
737 
738     }
739 
740     /**
741      * @throws SQLException
742      * @test java.sql.PreparedStatement#setFloat(int parameterIndex, float x)
743      */
744     @TestTargetNew(
745         level = TestLevel.COMPLETE,
746         notes = "",
747         method = "setFloat",
748         args = {int.class, float.class}
749     )
750     @KnownFailure("exception test fails")
testSetFloat()751     public void testSetFloat() throws SQLException {
752         float value1 = 12345678.12345689f;
753         float value2 = -12345678.12345689f;
754 
755         PreparedStatement ps = null;
756         String query = "insert into type (FloatVal) values (?);";
757         ps = conn.prepareStatement(query);
758 
759         try {
760 
761             Statement st = null;
762             try {
763                 ps.setFloat(1, value1);
764                 ps.execute();
765                 st = conn.createStatement();
766                 st.execute("select * from type where FloatVal=" + value1);
767                 ResultSet rs = st.getResultSet();
768                 assertEquals(1, getCount(rs));
769             } catch (SQLException sqle) {
770                 fail("SQLException is thrown: " + sqle.getMessage());
771             } finally {
772                 try {
773                     st.close();
774                 } catch (Exception ee) {
775                 }
776             }
777 
778             try {
779                 ps.setFloat(1, value2);
780                 ps.execute();
781                 st = conn.createStatement();
782                 st.execute("select * from type where FloatVal=" + value2);
783                 ResultSet rs = st.getResultSet();
784                 assertEquals(1, getCount(rs));
785             } catch (SQLException sqle) {
786                 fail("SQLException is thrown: " + sqle.getMessage());
787             } finally {
788                 try {
789                     st.close();
790                 } catch (SQLException ee) {
791 
792                 }
793             }
794             ps.close();
795             try {
796                 ps.setFloat(1, Float.MIN_VALUE);
797                 fail("SQLException is not thrown");
798             } catch (SQLException sqle) {
799                 // expected
800             }
801 
802         } catch (SQLException e) {
803             fail("SQLException is thrown: " + e.getMessage());
804         } finally {
805             try {
806 
807                 ps.close();
808             } catch (SQLException ee) {
809             }
810         }
811     }
812 
813     /**
814      * @throws SQLException
815      * @test java.sql.PreparedStatement#setDouble(int parameterIndex, double x)
816      */
817     @TestTargetNew(
818         level = TestLevel.COMPLETE,
819         notes = "",
820         method = "setDouble",
821         args = {int.class, double.class}
822     )
823     @KnownFailure("exception test fails")
testSetDouble()824     public void testSetDouble() throws SQLException {
825 
826         PreparedStatement ps = null;
827         String query = "insert into type (DoubleVal) values (?);";
828         ps = conn.prepareStatement(query);
829 
830         try {
831 
832             Statement st = null;
833             try {
834                 ps.setDouble(1, Double.MAX_VALUE);
835                 ps.execute();
836                 st = conn.createStatement();
837                 st.execute("select * from type where DoubleVal="
838                         + Double.MAX_VALUE);
839                 ResultSet rs = st.getResultSet();
840                 assertEquals(1, getCount(rs));
841             } catch (SQLException sqle) {
842                 fail("SQLException is thrown: " + sqle.getMessage());
843             } finally {
844                 try {
845                     st.close();
846                 } catch (Exception ee) {
847                 }
848             }
849 
850             try {
851                 ps.setDouble(1, Double.MIN_VALUE);
852                 ps.execute();
853                 st = conn.createStatement();
854                 st.execute("select * from type where DoubleVal="
855                         + Double.MIN_VALUE);
856                 ResultSet rs = st.getResultSet();
857                 assertEquals(1, getCount(rs));
858             } catch (SQLException sqle) {
859                 fail("SQLException is thrown: " + sqle.getMessage());
860             } finally {
861                 try {
862                     st.close();
863                 } catch (SQLException ee) {
864                 }
865             }
866 
867             ps.close();
868             try {
869                 ps.setDouble(1, 2.0);
870                 fail("SQLException is not thrown");
871             } catch (SQLException sqle) {
872                 // expected
873             }
874 
875         } catch (SQLException e) {
876             fail("SQLException is thrown: " + e.getMessage());
877         } finally {
878             try {
879 
880                 ps.close();
881             } catch (SQLException ee) {
882             }
883         }
884 
885     }
886 
887     /**
888      * @test java.sql.PreparedStatement#setString(int parameterIndex, String x)
889      */
890     @TestTargetNew(
891         level = TestLevel.COMPLETE,
892         notes = "",
893         method = "setString",
894         args = {int.class, java.lang.String.class}
895     )
896     @KnownFailure("exception test fails")
testSetString_charField()897     public void testSetString_charField() {
898 
899         PreparedStatement ps = null;
900 
901         try {
902             String query = "insert into type (charStr) values (?);";
903             ps = conn.prepareStatement(query);
904 
905             String str = "test^text$test%";
906             Statement st = null;
907             try {
908                 ps.setString(1, str);
909                 ps.execute();
910                 st = conn.createStatement();
911                 st.execute("select * from type where charStr='" + str + "'");
912                 ResultSet rs = st.getResultSet();
913                 assertEquals(1, getCount(rs));
914             } catch (SQLException sqle) {
915                 fail("SQLException is thrown: " + sqle.getMessage());
916             } finally {
917                 try {
918                     st.close();
919                 } catch (Exception ee) {
920                 }
921             }
922 
923             try {
924                 ps.setString(1, "");
925                 ps.execute();
926                 st = conn.createStatement();
927                 st.execute("select * from type where charStr=''");
928                 ResultSet rs = st.getResultSet();
929                 assertEquals(1, getCount(rs));
930             } catch (SQLException sqle) {
931                 fail("SQLException is thrown: " + sqle.getMessage());
932             } finally {
933                 try {
934                     st.close();
935                 } catch (SQLException ee) {
936                 }
937             }
938 
939             try {
940                 ps.setString(1, "                   ");
941                 ps.execute();
942                 st = conn.createStatement();
943                 st
944                         .execute("select * from type where charStr='                   '");
945                 ResultSet rs = st.getResultSet();
946                 assertEquals(1, getCount(rs));
947             } catch (SQLException sqle) {
948                 fail("SQLException is thrown: " + sqle.getMessage());
949             } finally {
950                 try {
951                     st.close();
952                 } catch (SQLException ee) {
953                 }
954             }
955 
956             try {
957                 ps.setString(1, " test & text * test % text * test ^ text ");
958                 ps.execute();
959             } catch (SQLException sqle) {
960                 fail("SQLException is thrown");
961             }
962 
963             try {
964                 ps.setString(1, null);
965                 ps.execute();
966             } catch (SQLException sqle) {
967                 fail("SQLException is thrown: " + sqle.getMessage());
968             }
969 
970             ps.close();
971 
972             try {
973                 ps.setString(1, "test text");
974                 fail("SQLException is not thrown");
975             } catch (SQLException sqle) {
976                 // expected
977             }
978 
979         } catch (SQLException e) {
980             fail("SQLException is thrown: " + e.getMessage());
981         } finally {
982             try {
983 
984                 ps.close();
985             } catch (SQLException ee) {
986             }
987         }
988     }
989 
990     /**
991      * @test java.sql.PreparedStatement#setString(int parameterIndex, String x)
992      */
993     @TestTargetNew(
994         level = TestLevel.COMPLETE,
995         notes = "",
996         method = "setString",
997         args = {int.class, java.lang.String.class}
998     )
999     @KnownFailure("statment.close() does not wrap up")
testSetString_tinyTextField()1000     public void testSetString_tinyTextField() {
1001 
1002         PreparedStatement ps = null;
1003         try {
1004             String str = "test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test";
1005             String query = "insert into type (TText) values (?);";
1006             ps = conn.prepareStatement(query);
1007             Statement st = null;
1008             try {
1009                 ps.setString(1, str);
1010                 ps.execute();
1011                 st = conn.createStatement();
1012                 st.execute("select * from type where TText='" + str + "'");
1013                 ResultSet rs = st.getResultSet();
1014                 assertEquals(1, getCount(rs));
1015             } catch (SQLException sqle) {
1016                 fail("SQLException is thrown: " + sqle.getMessage());
1017             } finally {
1018                 try {
1019                     st.close();
1020                 } catch (Exception ee) {
1021                 }
1022             }
1023 
1024             try {
1025                 ps.setString(1, "");
1026                 ps.execute();
1027                 st = conn.createStatement();
1028                 st.execute("select * from type where TText=''");
1029                 ResultSet rs = st.getResultSet();
1030                 assertEquals(1, getCount(rs));
1031             } catch (SQLException sqle) {
1032                 fail("SQLException is thrown: " + sqle.getMessage());
1033             } finally {
1034                 try {
1035                     st.close();
1036                 } catch (SQLException ee) {
1037                 }
1038             }
1039 
1040             try {
1041                 ps.setString(1, "                   ");
1042                 ps.execute();
1043                 st = conn.createStatement();
1044                 st
1045                         .execute("select * from type where TText='                   '");
1046                 ResultSet rs = st.getResultSet();
1047                 assertEquals(1, getCount(rs));
1048             } catch (SQLException sqle) {
1049                 fail("SQLException is thrown: " + sqle.getMessage());
1050             } finally {
1051                 try {
1052                     st.close();
1053                 } catch (SQLException ee) {
1054                 }
1055             }
1056 
1057             try {
1058                 ps.setString(
1059                                 1,
1060                                 "test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test*test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test-test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test+test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test?test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test#test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test ");
1061                 ps.execute();
1062             } catch (SQLException sqle) {
1063                 fail("SQLException is thrown");
1064             }
1065 
1066             try {
1067                 ps.setString(1, null);
1068                 ps.execute();
1069             } catch (SQLException sqle) {
1070                 fail("SQLException is thrown: " + sqle.getMessage());
1071             }
1072 
1073             ps.close();
1074 
1075             try {
1076                 ps.setString(1, "test text");
1077                 fail("SQLException is not thrown");
1078             } catch (SQLException sqle) {
1079                 // expected
1080             }
1081 
1082 
1083         } catch (SQLException e) {
1084             fail("SQLException is thrown: " + e.getMessage());
1085         } finally {
1086             try {
1087 
1088                 ps.close();
1089             } catch (SQLException ee) {
1090             }
1091         }
1092     }
1093 
1094     /**
1095      * @test java.sql.PreparedStatement#setString(int parameterIndex, String x)
1096      */
1097     @TestTargetNew(
1098         level = TestLevel.COMPLETE,
1099         notes = "",
1100         method = "setString",
1101         args = {int.class, java.lang.String.class}
1102     )
testSetString_textField()1103     public void testSetString_textField() {
1104 
1105         PreparedStatement ps = null;
1106         try {
1107             String str = "test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test";
1108             String query = "insert into type (TextVal) values (?);";
1109             ps = conn.prepareStatement(query);
1110             Statement st = null;
1111             try {
1112                 ps.setString(1, str);
1113                 ps.execute();
1114                 st = conn.createStatement();
1115                 st.execute("select * from type where TextVal='" + str + "'");
1116                 ResultSet rs = st.getResultSet();
1117                 assertEquals(1, getCount(rs));
1118             } catch (SQLException sqle) {
1119                 fail("SQLException is thrown: " + sqle.getMessage());
1120             } finally {
1121                 try {
1122                     st.close();
1123                 } catch (Exception ee) {
1124                 }
1125             }
1126 
1127             try {
1128                 ps.setString(1, "");
1129                 ps.execute();
1130                 st = conn.createStatement();
1131                 st.execute("select * from type where TextVal=''");
1132                 ResultSet rs = st.getResultSet();
1133                 assertEquals(1, getCount(rs));
1134             } catch (SQLException sqle) {
1135                 fail("SQLException is thrown: " + sqle.getMessage());
1136             } finally {
1137                 try {
1138                     st.close();
1139                 } catch (SQLException ee) {
1140                 }
1141             }
1142 
1143             try {
1144                 ps.setString(1, "                   ");
1145                 ps.execute();
1146                 st = conn.createStatement();
1147                 st
1148                         .execute("select * from type where TextVal='                   '");
1149                 ResultSet rs = st.getResultSet();
1150                 assertEquals(1, getCount(rs));
1151             } catch (SQLException sqle) {
1152                 fail("SQLException is thrown: " + sqle.getMessage());
1153             } finally {
1154                 try {
1155                     st.close();
1156                 } catch (SQLException ee) {
1157                 }
1158             }
1159 
1160 
1161             try {
1162                 String longString = " test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/";
1163                 for (int i = 0; i < 10; i++) {
1164                     longString += longString;
1165                 }
1166                 ps.setString(1, longString);
1167                 ps.execute();
1168 
1169             } catch (SQLException sqle) {
1170                 fail("SQLException is thrown");
1171             }
1172 
1173             try {
1174                 ps.setString(1, null);
1175                 ps.execute();
1176             } catch (SQLException sqle) {
1177                 fail("SQLException is thrown: " + sqle.getMessage());
1178             }
1179 
1180             ps.close();
1181 
1182             try {
1183                 ps.setString(2, "test text");
1184                 fail("SQLException is not thrown");
1185             } catch (SQLException sqle) {
1186                 // expected
1187             }
1188         } catch (SQLException e) {
1189             fail("SQLException is thrown: " + e.getMessage());
1190         } finally {
1191             try {
1192 
1193                 ps.close();
1194             } catch (SQLException ee) {
1195             }
1196         }
1197     }
1198 
1199     /**
1200      * @test java.sql.PreparedStatement#setString(int parameterIndex, String x)
1201      */
1202     @TestTargetNew(
1203         level = TestLevel.COMPLETE,
1204         notes = "",
1205         method = "setString",
1206         args = {int.class, java.lang.String.class}
1207     )
testSetString_mediumTextField()1208     public void testSetString_mediumTextField() {
1209 
1210         PreparedStatement ps = null;
1211         try {
1212             String str = "test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test";
1213             String query = "insert into type (MText) values (?);";
1214             ps = conn.prepareStatement(query);
1215             Statement st = null;
1216             try {
1217                 ps.setString(1, str);
1218                 ps.execute();
1219                 st = conn.createStatement();
1220                 st.execute("select * from type where MText='" + str + "'");
1221                 ResultSet rs = st.getResultSet();
1222                 assertEquals(1, getCount(rs));
1223             } catch (SQLException sqle) {
1224                 fail("SQLException is thrown: " + sqle.getMessage());
1225             } finally {
1226                 try {
1227                     st.close();
1228                 } catch (Exception ee) {
1229                 }
1230             }
1231 
1232             try {
1233                 ps.setString(1, "");
1234                 ps.execute();
1235                 st = conn.createStatement();
1236                 st.execute("select * from type where MText=''");
1237                 ResultSet rs = st.getResultSet();
1238                 assertEquals(1, getCount(rs));
1239             } catch (SQLException sqle) {
1240                 fail("SQLException is thrown: " + sqle.getMessage());
1241             } finally {
1242                 try {
1243                     st.close();
1244                 } catch (Exception ee) {
1245                 }
1246             }
1247 
1248             try {
1249                 ps.setString(1, "                   ");
1250                 ps.execute();
1251                 st = conn.createStatement();
1252                 st
1253                         .execute("select * from type where MText='                   '");
1254                 ResultSet rs = st.getResultSet();
1255                 assertEquals(1, getCount(rs));
1256             } catch (SQLException sqle) {
1257                 fail("SQLException is thrown: " + sqle.getMessage());
1258             } finally {
1259                 try {
1260                     st.close();
1261                 } catch (Exception ee) {
1262                 }
1263             }
1264 
1265             try {
1266                 ps.setString(1, null);
1267                 ps.execute();
1268             } catch (SQLException sqle) {
1269                 fail("SQLException is thrown: " + sqle.getMessage());
1270             }
1271 
1272             ps.close();
1273 
1274             try {
1275                 ps.setString(2, "test text");
1276                 fail("SQLException is not thrown");
1277             } catch (SQLException sqle) {
1278                 // expected
1279             }
1280 
1281 
1282 
1283         } catch (SQLException e) {
1284             fail("SQLException is thrown: " + e.getMessage());
1285         } finally {
1286             try {
1287 
1288                 ps.close();
1289             } catch (Exception ee) {
1290             }
1291         }
1292     }
1293 
1294     /**
1295      * @test java.sql.PreparedStatement#setString(int parameterIndex, String x)
1296      */
1297     @TestTargetNew(
1298         level = TestLevel.COMPLETE,
1299         notes = "",
1300         method = "setString",
1301         args = {int.class, java.lang.String.class}
1302     )
1303     @KnownFailure("exception test fails")
testSetString_longTextField()1304     public void testSetString_longTextField() {
1305 
1306         PreparedStatement ps = null;
1307         try {
1308             String str = "test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test/test^text$test%test(text)test@text5test~test^text$test%test(text)test@text5test";
1309             String query = "insert into type (LText) values (?);";
1310             ps = conn.prepareStatement(query);
1311             Statement st = null;
1312             try {
1313                 ps.setString(1, str);
1314                 ps.execute();
1315                 st = conn.createStatement();
1316                 st.execute("select * from type where LText='" + str + "'");
1317                 ResultSet rs = st.getResultSet();
1318                 assertEquals(1, getCount(rs));
1319             } catch (SQLException sqle) {
1320                 fail("SQLException is thrown: " + sqle.getMessage());
1321             } finally {
1322                 try {
1323                     st.close();
1324                 } catch (Exception ee) {
1325                 }
1326             }
1327 
1328             try {
1329                 ps.setString(1, "");
1330                 ps.execute();
1331                 st = conn.createStatement();
1332                 st.execute("select * from type where LText=''");
1333                 ResultSet rs = st.getResultSet();
1334                 assertEquals(1, getCount(rs));
1335             } catch (SQLException sqle) {
1336                 fail("SQLException is thrown: " + sqle.getMessage());
1337             } finally {
1338                 try {
1339                     st.close();
1340                 } catch (Exception ee) {
1341                 }
1342             }
1343 
1344             try {
1345                 ps.setString(1, "                   ");
1346                 ps.execute();
1347                 st = conn.createStatement();
1348                 st
1349                         .execute("select * from type where LText='                   '");
1350                 ResultSet rs = st.getResultSet();
1351                 assertEquals(1, getCount(rs));
1352             } catch (SQLException sqle) {
1353                 fail("SQLException is thrown: " + sqle.getMessage());
1354             } finally {
1355                 try {
1356                     st.close();
1357                 } catch (Exception ee) {
1358                 }
1359             }
1360 
1361             try {
1362                 ps.setString(1, null);
1363                 ps.execute();
1364             } catch (SQLException sqle) {
1365                 fail("SQLException is thrown: " + sqle.getMessage());
1366             }
1367 
1368             ps.close();
1369 
1370             try {
1371                 ps.setString(1, "test text");
1372                 fail("SQLException is not thrown");
1373             } catch (SQLException sqle) {
1374                 // expected
1375             }
1376 
1377 
1378         } catch (SQLException e) {
1379             fail("SQLException is thrown: " + e.getMessage());
1380         } finally {
1381             try {
1382 
1383                 ps.close();
1384             } catch (Exception ee) {
1385             }
1386         }
1387     }
1388 
1389     /**
1390      * @test java.sql.PreparedStatement#setShort(int parameterIndex, short x)
1391      */
1392     @TestTargetNew(
1393         level = TestLevel.COMPLETE,
1394         notes = "",
1395         method = "setShort",
1396         args = {int.class, short.class}
1397     )
1398     @KnownFailure("exception test fails")
testSetShort()1399     public void testSetShort() {
1400 
1401         PreparedStatement ps = null;
1402         PreparedStatement ps1 = null;
1403         PreparedStatement ps2 = null;
1404         try {
1405             String query = "insert into type (Sint) values (?);";
1406             ps = conn.prepareStatement(query);
1407             Statement st = null;
1408             try {
1409                 ps.setShort(1, Short.MAX_VALUE);
1410                 ps.execute();
1411                 st = conn.createStatement();
1412                 st.execute("select * from type where Sint=" + Short.MAX_VALUE);
1413                 ResultSet rs = st.getResultSet();
1414                 assertEquals(1, getCount(rs));
1415             } catch (SQLException sqle) {
1416                 fail("SQLException is thrown: " + sqle.getMessage());
1417             } finally {
1418                 try {
1419                     st.close();
1420                 } catch (Exception ee) {
1421                 }
1422             }
1423 
1424             try {
1425                 ps.setShort(1, Short.MIN_VALUE);
1426                 ps.execute();
1427                 st = conn.createStatement();
1428                 st.execute("select * from type where Sint=" + Short.MIN_VALUE);
1429                 ResultSet rs = st.getResultSet();
1430                 assertEquals(1, getCount(rs));
1431             } catch (SQLException sqle) {
1432                 fail("SQLException is thrown: " + sqle.getMessage());
1433             } finally {
1434                 try {
1435                     st.close();
1436                 } catch (Exception ee) {
1437                 }
1438             }
1439 
1440             ps.close();
1441 
1442             try {
1443                 ps.setShort(1, Short.MIN_VALUE);
1444                 fail("SQLException is not thrown");
1445             } catch (SQLException sqle) {
1446                 // expected
1447             }
1448 
1449             String query1 = "insert into type (Tint) values (?);";
1450             ps1 = conn.prepareStatement(query1);
1451             try {
1452                 ps1.setShort(1, Short.MAX_VALUE);
1453             } catch (SQLException sqle) {
1454                 fail("SQLException is thrown: "+sqle.getMessage());
1455             }
1456 
1457             String query2 = "insert into type (IntVal) values (?);";
1458             ps2 = conn.prepareStatement(query2);
1459             try {
1460                 ps2.setShort(1, Short.MAX_VALUE);
1461                 ps2.execute();
1462                 st = conn.createStatement();
1463                 st
1464                         .execute("select * from type where IntVal="
1465                                 + Short.MAX_VALUE);
1466                 ResultSet rs = st.getResultSet();
1467                 assertEquals(1, getCount(rs));
1468             } catch (SQLException sqle) {
1469                 fail("SQLException is thrown: " + sqle.getMessage());
1470             }
1471         } catch (SQLException e) {
1472             fail("SQLException is thrown: " + e.getMessage());
1473         } finally {
1474             try {
1475 
1476                 ps.close();
1477                 ps1.close();
1478                 ps2.close();
1479             } catch (Exception ee) {
1480             }
1481         }
1482     }
1483 
1484     /**
1485      * @test java.sql.PreparedStatement#setBoolean(int parameterIndex, boolean
1486      *       x)
1487      */
1488     @TestTargetNew(
1489         level = TestLevel.COMPLETE,
1490         notes = "",
1491         method = "setBoolean",
1492         args = {int.class, boolean.class}
1493     )
1494     @KnownFailure("exception test fails")
testSetBoolean()1495     public void testSetBoolean() {
1496 
1497         PreparedStatement ps = null;
1498         PreparedStatement ps1 = null;
1499         try {
1500             String query = "insert into type (BoolVal) values (?);";
1501             ps = conn.prepareStatement(query);
1502             Statement st = null;
1503             try {
1504                 ps.setBoolean(1, false);
1505                 ps.execute();
1506                 st = conn.createStatement();
1507                 st.execute("select * from type where BoolVal = 0");
1508                 ResultSet rs = st.getResultSet();
1509                 assertEquals(1, getCount(rs));
1510             } catch (SQLException sqle) {
1511                 fail("SQLException is thrown: " + sqle.getMessage());
1512             } finally {
1513                 try {
1514                     st.close();
1515                 } catch (Exception ee) {
1516                 }
1517             }
1518 
1519             try {
1520                 ps.setBoolean(1, true);
1521                 ps.execute();
1522                 st = conn.createStatement();
1523                 st.execute("select * from type where BoolVal= 1");
1524                 ResultSet rs = st.getResultSet();
1525                 assertEquals(2, getCount(rs));
1526             } catch (SQLException sqle) {
1527                 fail("SQLException is thrown: " + sqle.getMessage());
1528             } finally {
1529                 try {
1530                     st.close();
1531                 } catch (Exception ee) {
1532                 }
1533             }
1534 
1535             ps.close();
1536 
1537             try {
1538                 ps.setBoolean(1, false);
1539                 fail("SQLException is not thrown");
1540             } catch (SQLException sqle) {
1541                 // expected
1542             }
1543 
1544             String query1 = "insert into type (Tint) values (?);";
1545             ps1 = conn.prepareStatement(query1);
1546             try {
1547                 ps1.setBoolean(1, true);
1548                 ps1.execute();
1549             } catch (SQLException sqle) {
1550                 fail("SQLException is thrown: " + sqle.getMessage());
1551             }
1552 
1553         } catch (SQLException e) {
1554             fail("SQLException is thrown: " + e.getMessage());
1555         } finally {
1556             try {
1557 
1558                 ps.close();
1559                 ps1.close();
1560             } catch (Exception ee) {
1561             }
1562         }
1563     }
1564 
1565     /**
1566      * @test java.sql.PreparedStatement#setByte(int parameterIndex, byte x)
1567      */
1568     @TestTargetNew(
1569         level = TestLevel.COMPLETE,
1570         notes = "",
1571         method = "setByte",
1572         args = {int.class, byte.class}
1573     )
1574     @KnownFailure("exception test fails")
testSetByte()1575     public void testSetByte() {
1576 
1577         PreparedStatement ps = null;
1578         PreparedStatement ps1 = null;
1579         try {
1580             String query = "insert into type (Tint) values (?);";
1581             ps = conn.prepareStatement(query);
1582             Statement st = null;
1583             try {
1584                 ps.setByte(1, Byte.MAX_VALUE);
1585                 ps.execute();
1586                 st = conn.createStatement();
1587                 st.execute("select * from type where Tint=" + Byte.MAX_VALUE);
1588                 ResultSet rs = st.getResultSet();
1589                 assertEquals(1, getCount(rs));
1590             } catch (SQLException sqle) {
1591                 fail("SQLException is thrown: " + sqle.getMessage());
1592             } finally {
1593                 try {
1594                     st.close();
1595                 } catch (SQLException ee) {
1596                 }
1597             }
1598 
1599             try {
1600                 ps.setByte(1, Byte.MIN_VALUE);
1601                 ps.execute();
1602                 st = conn.createStatement();
1603                 st.execute("select * from type where Tint=" + Byte.MIN_VALUE);
1604                 ResultSet rs = st.getResultSet();
1605                 assertEquals(1, getCount(rs));
1606             } catch (SQLException sqle) {
1607                 fail("SQLException is thrown: " + sqle.getMessage());
1608             } finally {
1609                 try {
1610                     st.close();
1611                 } catch (SQLException ee) {
1612                 }
1613             }
1614 
1615             try {
1616                 ps.setByte(2, Byte.MAX_VALUE);
1617                 fail("SQLException is not thrown");
1618             } catch (Exception sqle) {
1619                 // expected
1620             }
1621 
1622             ps.close();
1623 
1624             try {
1625                 ps.setByte(1, Byte.MIN_VALUE);
1626                 fail("SQLException is not thrown");
1627             } catch (SQLException sqle) {
1628                 // expected
1629             }
1630 
1631             String query1 = "insert into type (IntVal) values (?);";
1632             ps1 = conn.prepareStatement(query1);
1633             try {
1634                 ps1.setByte(1, Byte.MAX_VALUE);
1635                 ps1.execute();
1636             } catch (SQLException sqle) {
1637                 fail("SQLException is thrown: " + sqle.getMessage());
1638             }
1639 
1640         } catch (SQLException e) {
1641             fail("SQLException is thrown: " + e.getMessage());
1642         } finally {
1643             try {
1644 
1645                 ps.close();
1646                 ps1.close();
1647             } catch (Exception ee) {
1648             }
1649         }
1650     }
1651 
1652     /**
1653      * @test java.sql.PreparedStatement#setBytes(int parameterIndex, byte[] x)
1654      */
1655     @TestTargetNew(
1656         level = TestLevel.COMPLETE,
1657         notes = "",
1658         method = "setBytes",
1659         args = {int.class, byte[].class}
1660     )
1661     @KnownFailure("preparedStatement.execute() does not return false on update.")
testSetBytes()1662     public void testSetBytes() {
1663 
1664         byte[] bytesArray = {1, 0};
1665 
1666         PreparedStatement ps = null;
1667         PreparedStatement ps1 = null;
1668         try {
1669             String query = "insert into type (LBlob) values (?);";
1670             ps = conn.prepareStatement(query);
1671 
1672             try {
1673                 ps.setBytes(1, bytesArray);
1674                 assertFalse(ps.execute());
1675                 assertTrue(ps.getUpdateCount() > 0);
1676             } catch (SQLException sqle) {
1677                 fail("SQLException is thrown: " + sqle.getMessage());
1678             }
1679 
1680             try {
1681                 ps.setBytes(2, bytesArray);
1682                 fail("SQLException is not thrown");
1683             } catch (Exception sqle) {
1684                 // expected RuntimeException or SQLException
1685             }
1686 
1687             ps.close();
1688 
1689             try {
1690                 ps.setBytes(1, bytesArray);
1691                 fail("SQLException is not thrown");
1692             } catch (SQLException sqle) {
1693                 // expected
1694             }
1695             String query1 = "insert into type (TBlob) values (?);";
1696             ps1 = conn.prepareStatement(query1);
1697 
1698             try {
1699                 ps.setBytes(1, bytesArray);
1700                 assertFalse(ps.execute());
1701                 assertTrue(ps.getUpdateCount() > 0);
1702             } catch (SQLException sqle) {
1703                 fail("SQLException is thrown: " + sqle.getMessage());
1704             }
1705 
1706         } catch (SQLException e) {
1707             fail("SQLException is thrown: " + e.getMessage());
1708         } finally {
1709             try {
1710 
1711                 if (ps != null) ps.close();
1712                 if (ps1 != null) ps1.close();
1713             } catch (Exception ee) {
1714             }
1715         }
1716     }
1717 
1718     /**
1719      * @test java.sql.PreparedStatement#setBigDecimal(int parameterIndex,
1720      *       BigDecimal x)
1721      */
1722     @TestTargetNew(
1723         level = TestLevel.COMPLETE,
1724         notes = "",
1725         method = "setBigDecimal",
1726         args = {int.class, java.math.BigDecimal.class}
1727     )
1728     @KnownFailure("preparedStatement.execute() does not return false on update.")
testSetBigDecimal()1729     public void testSetBigDecimal() {
1730 
1731         BigDecimal bd = new BigDecimal("50");
1732 
1733         PreparedStatement ps = null;
1734         PreparedStatement ps1 = null;
1735         try {
1736             String query = "insert into type (DecVal) values (?);";
1737             ps = conn.prepareStatement(query);
1738             Statement st = null;
1739             try {
1740                 ps.setBigDecimal(1, bd);
1741                 assertFalse(ps.execute());
1742                 assertTrue(ps.getUpdateCount() > 0);
1743             } catch (SQLException sqle) {
1744                 fail("SQLException is thrown: " + sqle.getMessage());
1745             }
1746 
1747 
1748             try {
1749                 ps.setBigDecimal(2, bd);
1750                 fail("SQLException is not thrown");
1751             } catch (SQLException sqle) {
1752                 // expected
1753                 assertEquals("bad parameter index", sqle.getMessage());
1754             }
1755 
1756             try {
1757                 ps.setBigDecimal(-2, bd);
1758                 fail("SQLException is not thrown");
1759             } catch (SQLException sqle) {
1760                 // expected
1761                 assertEquals("bad parameter index", sqle.getMessage());
1762             }
1763             String query1 = "insert into type (Tint) values (?);";
1764             ps1 = conn.prepareStatement(query1);
1765 
1766             try {
1767                 ps1.setBigDecimal(1, bd);
1768             } catch (SQLException sqle) {
1769                 fail("SQLException is thrown");
1770             }
1771         } catch (SQLException e) {
1772             fail("SQLException is thrown: " + e.getMessage());
1773         } finally {
1774             try {
1775 
1776                 if (ps != null) ps.close();
1777                 if (ps1 != null) ps1.close();
1778             } catch (SQLException ee) {
1779             }
1780         }
1781     }
1782 
1783     /**
1784      * @test java.sql.PreparedStatement#setDate(int parameterIndex, Date x)
1785      */
1786     @TestTargetNew(
1787         level = TestLevel.COMPLETE,
1788         notes = "First exception test fails: integer and date are incompatible"
1789                +" by spec.",
1790         method = "setDate",
1791         args = {int.class, java.sql.Date.class}
1792     )
1793     @KnownFailure("preparedStatement.execute() does not return false on update. "+
1794             "Setting a data for a declared INTEGER should throw Exception")
testSetDate_int_Date()1795     public void testSetDate_int_Date() {
1796         Calendar cal = new GregorianCalendar(1799, 5, 26);
1797 
1798         Date[] dates = {
1799                 new Date(cal.getTimeInMillis()), new Date(Integer.MAX_VALUE),
1800                 new Date(123456789)};
1801 
1802 
1803         PreparedStatement ps = null;
1804         PreparedStatement ps1 = null;
1805         try {
1806             String query = "insert into type (dateVal) values (?);";
1807             ps = conn.prepareStatement(query);
1808 
1809             for (int i = 0; i < dates.length; i++) {
1810                 try {
1811                     ps.setDate(1, dates[i]);
1812                     assertFalse(ps.execute());
1813                     assertTrue(ps.getUpdateCount() > 0);
1814                 } catch (SQLException sqle) {
1815                     fail("SQLException is thrown: " + sqle.getMessage());
1816                 }
1817             }
1818 
1819             try {
1820                 ps.setDate(2, dates[0]);
1821                 fail("SQLException is not thrown");
1822             } catch (Exception sqle) {
1823                 // expected
1824             }
1825 
1826             ps.close();
1827 
1828             try {
1829                 ps.setDate(1, dates[0]);
1830                 fail("SQLException is not thrown");
1831             } catch (SQLException sqle) {
1832                 // expected
1833             }
1834 
1835             String query1 = "insert into type (Tint) values (?);";
1836             ps1 = conn.prepareStatement(query1);
1837 
1838             try {
1839                 ps1.setDate(1, dates[0]);
1840                 fail("SQLException is not thrown");
1841             } catch (SQLException sqle) {
1842                 // expected
1843                 assertEquals("SQLite.Exception: error in prepare", sqle
1844                         .getMessage());
1845             }
1846         } catch (SQLException e) {
1847             fail("SQLException is thrown: " + e.getMessage());
1848         } finally {
1849             try {
1850 
1851                 if (ps != null) ps.close();
1852                 if (ps1 != null) ps1.close();
1853             } catch (SQLException ee) {
1854             }
1855         }
1856     }
1857 
1858     /**
1859      * @test java.sql.PreparedStatement#setDate(int parameterIndex, Date x,
1860      *       Calendar cal)
1861      */
1862     @TestTargetNew(
1863         level = TestLevel.COMPLETE,
1864         notes = "",
1865         method = "setDate",
1866         args = {int.class, java.sql.Date.class, java.util.Calendar.class}
1867     )
1868     @KnownFailure("preparedStatement.execute() does not return false on update.")
testSetDate_int_Date_Calendar()1869     public void testSetDate_int_Date_Calendar() {
1870 
1871         Calendar[] cals = { Calendar.getInstance(),
1872                 Calendar.getInstance(Locale.GERMANY),
1873                 Calendar.getInstance(TimeZone.getDefault()) };
1874         Calendar cal = new GregorianCalendar(1799,5,26);
1875 
1876         Date[] dates = { new Date(cal.getTimeInMillis()), new Date(Integer.MAX_VALUE),
1877                 new Date(123456789) };
1878 
1879 
1880         PreparedStatement ps = null;
1881         PreparedStatement ps1 = null;
1882         try {
1883             String query = "insert into type (dateVal) values (?);";
1884             ps = conn.prepareStatement(query);
1885 
1886             for (int i = 0; i < dates.length; i++) {
1887 
1888                 try {
1889                     ps.setDate(1, dates[i], cals[i]);
1890                     assertFalse(ps.execute());
1891                     assertTrue(ps.getUpdateCount() > 0);
1892                 } catch (SQLException sqle) {
1893                     fail("SQLException is thrown: " + sqle.getMessage());
1894                 }
1895             }
1896 
1897             try {
1898                 ps.setDate(2, dates[0], cals[0]);
1899                 ps.execute();
1900                 fail("SQLException is not thrown");
1901             } catch (Exception sqle) {
1902                 // expected
1903             }
1904 
1905             ps.close();
1906 
1907             try {
1908                 ps.setDate(1, dates[0], cals[1]);
1909                 fail("SQLException is not thrown");
1910             } catch (Exception sqle) {
1911                 // expected
1912             }
1913             String query1 = "insert into type (Tint) values (?);";
1914             ps1 = conn.prepareStatement(query1);
1915 
1916             try {
1917                 ps1.setDate(1, dates[0], cals[2]);
1918                 ps1.execute();
1919             } catch (SQLException sqle) {
1920                 fail("SQLException is thrown");
1921             }
1922 
1923         } catch (SQLException e) {
1924             fail("SQLException is thrown: " + e.getMessage());
1925         } finally {
1926             try {
1927 
1928                 if (ps != null) ps.close();
1929                 if (ps1 != null) ps1.close();
1930             } catch (SQLException ee) {
1931             }
1932         }
1933     }
1934 
1935     /**
1936      * @test java.sql.PreparedStatement#setNull(int parameterIndex, int sqlType)
1937      *
1938      * this test doesn't passed on RI
1939      */
1940     @TestTargetNew(
1941         level = TestLevel.COMPLETE,
1942         notes = "",
1943         method = "setNull",
1944         args = {int.class, int.class}
1945     )
testSetNull_int_int()1946     public void testSetNull_int_int() {
1947 
1948         PreparedStatement ps = null;
1949         try {
1950             String query = "insert into type (BoolVal, IntVal) values ('true', ?);";
1951             ps = conn.prepareStatement(query);
1952             Statement st = null;
1953             try {
1954                 ps.setNull(1, Types.INTEGER);
1955                 ps.execute();
1956             } catch (SQLException sqle) {
1957                 fail("SQLException is thrown: " + sqle.getMessage());
1958             } finally {
1959                 try {
1960                     ps.close();
1961                 } catch (Exception ee) {
1962                 }
1963             }
1964 
1965             query = "insert into type (BoolVal, LongVal) values ('true', ?);";
1966             ps = conn.prepareStatement(query);
1967 
1968             try {
1969                 ps.setNull(1, Types.BIGINT);
1970                 ps.execute();
1971             } catch (SQLException sqle) {
1972                 fail("SQLException is thrown: " + sqle.getMessage());
1973             } finally {
1974                 try {
1975                     ps.close();
1976                 } catch (Exception ee) {
1977                 }
1978             }
1979 
1980             query = "insert into type (BoolVal, DecVal) values ('true', ?)";
1981             ps = conn.prepareStatement(query);
1982 
1983             try {
1984                 ps.setNull(1, Types.DECIMAL);
1985                 ps.execute();
1986              } catch (SQLException sqle) {
1987                 fail("SQLException is thrown: " + sqle.getMessage());
1988             } finally {
1989                 try {
1990                     ps.close();
1991                 } catch (Exception ee) {
1992                 }
1993             }
1994 
1995             query = "insert into type (BoolVal, dateVal) values ('true', ?);";
1996             ps = conn.prepareStatement(query);
1997 
1998             try {
1999                 ps.setNull(1, Types.DATE);
2000                 ps.execute();
2001             } catch (SQLException sqle) {
2002                fail("SQLException is thrown: " + sqle.getMessage());
2003             } finally {
2004                 try {
2005                     ps.close();
2006                 } catch (Exception ee) {
2007                 }
2008             }
2009 
2010             query = "insert into type (BoolVal, BlobVal) values ('true', ?);";
2011             ps = conn.prepareStatement(query);
2012 
2013             try {
2014                 ps.setNull(1, Types.BLOB);
2015                 ps.execute();
2016             } catch (SQLException sqle) {
2017                fail("SQLException is thrown: " + sqle.getMessage());
2018             } finally {
2019                 try {
2020                     ps.close();
2021                 } catch (Exception ee) {
2022                 }
2023             }
2024 
2025             query = "insert into type (BoolVal, TextVal) values ('true', ?);";
2026             ps = conn.prepareStatement(query);
2027 
2028             try {
2029                 ps.setNull(1, Types.CHAR);
2030                 ps.execute();
2031             } catch (SQLException sqle) {
2032                fail("SQLException is thrown: " + sqle.getMessage());
2033             }
2034         } catch (SQLException e) {
2035             fail("SQLException is thrown: " + e.getMessage());
2036         } finally {
2037             try {
2038 
2039                 ps.close();
2040             } catch (Exception ee) {
2041             }
2042         }
2043     }
2044 
2045     /**
2046      * @test {@link java.sql.PreparedStatement#setNull(int, int, String)}
2047      *
2048      * UDTs and Ref types not supported in SQLite v 3
2049      */
2050     @TestTargetNew(
2051         level = TestLevel.COMPLETE,
2052         notes = "not supported",
2053         method = "setNull",
2054         args = {int.class, int.class, java.lang.String.class}
2055     )
testSetNullIntintString()2056     public void testSetNullIntintString() {
2057         // test UDT
2058         String typeCreationStmtUDT = "CREATE TYPE addressType AS "
2059         +"( street INTEGER, zip TEXT);";
2060         String personTableCreateUDT = "CREATE TABLE person (name TEXT, address addressType);";
2061         Statement st = null;
2062         PreparedStatement ps = null;
2063         try {
2064             st = conn.createStatement();
2065             st.execute(typeCreationStmtUDT);
2066             st.execute(personTableCreateUDT);
2067             fail("UDTs and Ref Types not supported");
2068             String query = "insert into person (name, address) values ('Hans', ?);";
2069             ps = conn.prepareStatement(query);
2070             try {
2071                 ps.setNull(1, Types.DATALINK);
2072                 ps.execute();
2073             } catch (SQLException sqle) {
2074                 fail("SQLException is thrown: " + sqle.getMessage());
2075                 sqle.printStackTrace();
2076             } finally {
2077                 try {
2078                     st.close();
2079                 } catch (Exception ee) {
2080                 }
2081             }
2082 
2083         } catch (SQLException e) {
2084          // UDTs or Ref types not supported
2085            // ok
2086         } finally {
2087             try {
2088                 st.execute("drop table if exists person");
2089                 ps.close();
2090             } catch (Exception ee) {
2091             }
2092         }
2093 
2094         // test non UDT REF type Exception checking
2095         String personTableCreate = "create table person (name TEXT, Address TEXT)";
2096             try {
2097 
2098                 st = conn.createStatement();
2099                 st.execute(personTableCreate);
2100                 String insert = "insert into person (name, address) values (?, '1600 Amphitheatre Mountain View');";
2101                 ps = conn.prepareStatement(insert);
2102                 try {
2103                     ps.setNull(1,1, "");
2104                     ps.execute();
2105                 } catch (SQLException sqle) {
2106                     assertEquals("SQLite.Exception: error in step",sqle.getMessage());
2107                 } finally {
2108                     try {
2109                         st.close();
2110                     } catch (Exception ee) {
2111                     }
2112                 }
2113 
2114             } catch (SQLException e) {
2115                 fail("SQLException is thrown: " + e.getMessage());
2116                 e.printStackTrace();
2117             } finally {
2118                 try {
2119                     st.execute("drop table if exists person");
2120                     ps.close();
2121                 } catch (Exception ee) {
2122                 }
2123             }
2124 
2125          // test non UDT REF type OK
2126 
2127             personTableCreate = "create table person (name TEXT, Address TEXT)";
2128                 try {
2129 
2130                     st = conn.createStatement();
2131                     st.execute("drop table if exists person");
2132                     st.execute(personTableCreate);
2133                     String insert = "insert into person (name, address) values (?, '1600 Amphitheatre Mountain View');";
2134                     ps = conn.prepareStatement(insert);
2135                     try {
2136                         ps.setNull(1,1, "");
2137                         ps.execute();
2138                     } catch (SQLException sqle) {
2139                         fail("SQLException is thrown: " + sqle.getMessage());
2140                         sqle.printStackTrace();
2141                     } finally {
2142                         try {
2143                             st.close();
2144                         } catch (Exception ee) {
2145                         }
2146                     }
2147 
2148                 } catch (SQLException e) {
2149                     fail("SQLException is thrown: " + e.getMessage());
2150                     e.printStackTrace();
2151                 } finally {
2152                     try {
2153                         st.execute("drop table if exists person");
2154                         ps.close();
2155                     } catch (Exception ee) {
2156                     }
2157                 }
2158 
2159 
2160     }
2161 
2162 
2163     /**
2164      * @test java.sql.PreparedStatement#setObject(int parameterIndex, Object x)
2165      *
2166      */
2167     @TestTargetNew(
2168         level = TestLevel.COMPLETE,
2169         notes = "",
2170         method = "setObject",
2171         args = {int.class, java.lang.Object.class}
2172     )
2173     @KnownFailure("exception test fails")
testSetObject_int_Object()2174     public void testSetObject_int_Object() {
2175 
2176         PreparedStatement ps = null;
2177         try {
2178             String query = "insert into type (IntVal) values (?);";
2179             ps = conn.prepareStatement(query);
2180             Statement st = null;
2181             try {
2182                 ps.setObject(1, Integer.MAX_VALUE);
2183                 ps.execute();
2184                 st = conn.createStatement();
2185                 st.execute("select * from type where IntVal="
2186                         + Integer.MAX_VALUE);
2187                 ResultSet rs = st.getResultSet();
2188                 assertEquals(1, getCount(rs));
2189             } catch (SQLException sqle) {
2190                 fail("SQLException is thrown: " + sqle.getMessage());
2191             } finally {
2192                 try {
2193                     st.close();
2194                 } catch (Exception ee) {
2195                 }
2196             }
2197 
2198             query = "insert into type (LongVal) values (?);";
2199             ps = conn.prepareStatement(query);
2200 
2201             try {
2202                 ps.setObject(1, "test text");
2203                 ps.execute();
2204                 st = conn.createStatement();
2205                 st.execute("select * from type where LongVal='test text';");
2206                 ResultSet rs = st.getResultSet();
2207                 assertEquals(1, getCount(rs));
2208             } catch (SQLException sqle) {
2209                 fail("SQLException is thrown: " + sqle.getMessage());
2210             } finally {
2211                 try {
2212                     st.close();
2213                 } catch (SQLException ee) {
2214                 }
2215             }
2216 
2217             query = "insert into type (DecVal) values (?);";
2218             ps = conn.prepareStatement(query);
2219 
2220             try {
2221                 ps.setObject(1, new Object());
2222                 ps.execute();
2223             } catch (SQLException sqle) {
2224                 fail("SQLException is thrown");
2225             }
2226 
2227             query = "insert into type (dateVal) values (?);";
2228             ps = conn.prepareStatement(query);
2229             Date d = new Date(123456789);
2230 
2231             try {
2232                 ps.setObject(1, d);
2233                 ps.execute();
2234                 st = conn.createStatement();
2235                 st.execute("select * from type where dateVal='"
2236                         + d.getTime() + "';");
2237                 ResultSet rs = st.getResultSet();
2238                 assertEquals(1, getCount(rs));
2239             } catch (SQLException sqle) {
2240                 fail("SQLException is thrown: " + sqle.getMessage());
2241             } finally {
2242                 try {
2243                     st.close();
2244                 } catch (Exception ee) {
2245                 }
2246             }
2247 
2248             // this sub test doesn't pass on RI
2249             query = "insert into type (BlobVal) values (?);";
2250             ps = conn.prepareStatement(query);
2251 
2252             try {
2253                 ps.setObject(1, null);
2254                 ps.execute();
2255             } catch (SQLException sqle) {
2256                 fail("SQLException is thrown: " + sqle.getMessage());
2257             } finally {
2258                 try {
2259                     st.close();
2260                 } catch (SQLException ee) {
2261                 }
2262             }
2263 
2264         } catch (SQLException e) {
2265             fail("SQLException is thrown: " + e.getMessage());
2266         } finally {
2267             try {
2268 
2269                 ps.close();
2270             } catch (Exception ee) {
2271             }
2272         }
2273         try {
2274             ps.setObject(1, "test text");
2275             fail("Exception not thrown");
2276         } catch (SQLException e) {
2277             // ok
2278         }
2279 
2280     }
2281 
2282     /**
2283      * @test java.sql.PreparedStatement#setObject(int parameterIndex, Object x,
2284      *       int targetSqlType)
2285      *
2286      * this test doesn't pass on RI
2287      */
2288     @TestTargetNew(
2289         level = TestLevel.SUFFICIENT,
2290         notes = "not all types supported",
2291         method = "setObject",
2292         args = {int.class, java.lang.Object.class, int.class}
2293     )
2294     @KnownFailure("Fails for Types.DATE")
testSetObject_int_Object_int()2295     public void testSetObject_int_Object_int() {
2296 
2297         PreparedStatement ps = null;
2298         try {
2299             String query = "insert into type (IntVal) values (?);";
2300             ps = conn.prepareStatement(query);
2301             Statement st = null;
2302             try {
2303                 ps.setObject(1, Integer.MAX_VALUE, Types.INTEGER);
2304                 ps.execute();
2305                 st = conn.createStatement();
2306                 st.execute("select * from type where IntVal="
2307                         + Integer.MAX_VALUE);
2308                 ResultSet rs = st.getResultSet();
2309                 assertEquals(1, getCount(rs));
2310             } catch (SQLException sqle) {
2311                 fail("SQLException is thrown: " + sqle.getMessage());
2312             } finally {
2313                 try {
2314                     st.close();
2315                 } catch (Exception ee) {
2316                 }
2317             }
2318 
2319             query = "insert into type (LongVal) values (?);";
2320             ps = conn.prepareStatement(query);
2321 
2322             try {
2323                 ps.setObject(1, "test text", Types.CHAR);
2324                 ps.execute();
2325                 st = conn.createStatement();
2326                 st.execute("select * from type where LongVal='test text';");
2327                 ResultSet rs = st.getResultSet();
2328                 assertEquals(1, getCount(rs));
2329             } catch (SQLException sqle) {
2330                 fail("SQLException is thrown: " + sqle.getMessage());
2331             } finally {
2332                 try {
2333                     st.close();
2334                 } catch (Exception ee) {
2335                 }
2336             }
2337 
2338             query = "insert into type (DecVal) values (?);";
2339             ps = conn.prepareStatement(query);
2340 
2341             try {
2342                 ps.setObject(1, new Object(), Types.DECIMAL);
2343                 ps.execute();
2344             } catch (SQLException sqle) {
2345                 fail("SQLException is thrown: " + sqle.toString());
2346             }
2347 
2348             query = "insert into type (dateVal) values (?);";
2349             ps = conn.prepareStatement(query);
2350             Date d = new Date(123456789);
2351 
2352 
2353             try {
2354                 ps.setObject(1, d, Types.DATE);
2355                 ps.execute();
2356                 st = conn.createStatement();
2357                 st.execute("select * from type where dateVal='"
2358                         + d.getTime() + "';");
2359                 ResultSet rs = st.getResultSet();
2360                 assertEquals(1, getCount(rs));
2361             } catch (SQLException sqle) {
2362                 fail("SQLException is thrown: " + sqle.getMessage());
2363             } finally {
2364                 try {
2365                     st.close();
2366                 } catch (Exception ee) {
2367                 }
2368             }
2369 
2370             // this sub test doesn't pass on RI
2371             query = "insert into type (BlobVal) values (?);";
2372             ps = conn.prepareStatement(query);
2373 
2374             try {
2375                 ps.setObject(1, "", Types.BLOB);
2376                 ps.execute();
2377             } catch (SQLException sqle) {
2378                 fail("SQLException is thrown: " + sqle.getMessage());
2379             } finally {
2380                 try {
2381                     st.close();
2382                 } catch (Exception ee) {
2383                 }
2384             }
2385 
2386         } catch (SQLException e) {
2387             fail("SQLException is thrown: " + e.getMessage());
2388         } finally {
2389             try {
2390 
2391                 ps.close();
2392             } catch (Exception ee) {
2393             }
2394         }
2395 
2396         try {
2397             ps.setObject(1, Integer.MAX_VALUE, Types.INTEGER);
2398             fail("Exception not thrown");
2399         } catch (SQLException e) {
2400             // ok
2401         }
2402 
2403     }
2404 
2405     /**
2406      * @test java.sql.PreparedStatement#setObject(int parameterIndex, Object x,
2407      *       int targetSqlType, int scale)
2408      *
2409      * this test doesn't pass on RI
2410      */
2411     @TestTargetNew(
2412         level = TestLevel.COMPLETE,
2413         notes = "",
2414         method = "setObject",
2415         args = {int.class, java.lang.Object.class, int.class, int.class}
2416     )
2417     @KnownFailure("Fails for Types.DATE")
testSetObject_int_Object_int_int()2418     public void testSetObject_int_Object_int_int() {
2419 
2420         PreparedStatement ps = null;
2421         try {
2422             String query = "insert into type (IntVal) values (?);";
2423             ps = conn.prepareStatement(query);
2424             Statement st = null;
2425             try {
2426                 ps.setObject(1, Integer.MAX_VALUE, Types.INTEGER,
2427                         Integer.MAX_VALUE);
2428                 ps.execute();
2429                 st = conn.createStatement();
2430                 st.execute("select * from type where IntVal="
2431                         + Integer.MAX_VALUE);
2432                 ResultSet rs = st.getResultSet();
2433                 assertEquals(1, getCount(rs));
2434             } catch (SQLException sqle) {
2435                 fail("SQLException is thrown: " + sqle.getMessage());
2436             } finally {
2437                 try {
2438                     st.close();
2439                 } catch (Exception ee) {
2440                 }
2441             }
2442 
2443             query = "insert into type (LongVal) values (?);";
2444             ps = conn.prepareStatement(query);
2445 
2446             try {
2447                 ps.setObject(1, "test text", Types.CHAR, Integer.MIN_VALUE);
2448                 ps.execute();
2449                 st = conn.createStatement();
2450                 st.execute("select * from type where LongVal='test text';");
2451                 ResultSet rs = st.getResultSet();
2452                 assertEquals(1, getCount(rs));
2453             } catch (SQLException sqle) {
2454                 fail("SQLException is thrown: " + sqle.getMessage());
2455             } finally {
2456                 try {
2457                     st.close();
2458                 } catch (Exception ee) {
2459                 }
2460             }
2461 
2462             query = "insert into type (DecVal) values (?);";
2463             ps = conn.prepareStatement(query);
2464             BigDecimal bd2 = new BigDecimal("12.21");
2465 
2466             try {
2467                 ps.setObject(1, bd2, Types.DECIMAL, 2);
2468                 ps.execute();
2469             } catch (SQLException sqle) {
2470                 fail("SQLException is thrown: " + sqle.getMessage());
2471             }
2472 
2473             query = "insert into type (dateVal) values (?);";
2474             ps = conn.prepareStatement(query);
2475             Date d = new Date(123456789);
2476             try {
2477                 ps.setObject(1, d , Types.DATE, -1);
2478                 ps.execute();
2479                 st = conn.createStatement();
2480                 st.execute("select * from type where dateVal='"
2481                         + d.getTime() + "';");
2482                 ResultSet rs = st.getResultSet();
2483                 assertEquals(1, getCount(rs));
2484             } catch (SQLException sqle) {
2485                 fail("SQLException is thrown: " + sqle.getMessage());
2486             } finally {
2487                 try {
2488                     st.close();
2489                 } catch (Exception ee) {
2490                 }
2491             }
2492 
2493             // this sub test doesn't pass on RI
2494             query = "insert into type(BlobVal) values (?);";
2495             ps = conn.prepareStatement(query);
2496 
2497             try {
2498                 ps.setObject(1, "", Types.BLOB, 0);
2499                 ps.execute();
2500             } catch (SQLException sqle) {
2501                 fail("SQLException is thrown: " + sqle.getMessage());
2502             } finally {
2503                 try {
2504                     st.close();
2505                 } catch (Exception ee) {
2506                 }
2507             }
2508 
2509         } catch (SQLException e) {
2510             fail("SQLException is thrown: " + e.getMessage());
2511         } finally {
2512             try {
2513 
2514                 ps.close();
2515             } catch (Exception ee) {
2516             }
2517         }
2518 
2519         try {
2520             ps.setObject(1, "test text", Types.CHAR, Integer.MIN_VALUE);
2521             fail("Exception not thrown");
2522         } catch (SQLException e) {
2523             // ok
2524         }
2525     }
2526 
2527     /**
2528      * @test java.sql.PreparedStatement#setTime(int parameterIndex, Time x)
2529      */
2530     @TestTargetNew(
2531         level = TestLevel.COMPLETE,
2532         notes = "",
2533         method = "setTime",
2534         args = {int.class, java.sql.Time.class}
2535     )
2536     @KnownFailure("statment.close() does not wrap up")
testSetTimeint_Time()2537     public void testSetTimeint_Time() {
2538 
2539         Time[] times = { new Time(24, 25, 26), new Time(Integer.MAX_VALUE),
2540                 new Time(123456789) };
2541 
2542 
2543         PreparedStatement ps = null;
2544         PreparedStatement ps1 = null;
2545         try {
2546             String query = "insert into type (timeVal) values (?);";
2547             ps = conn.prepareStatement(query);
2548             Statement st = null;
2549             for (int i = 0; i < times.length; i++) {
2550                 try {
2551                     ps.setTime(1, times[i]);
2552                     ps.execute();
2553                     st = conn.createStatement();
2554                     st.execute("select * from type where timeVal='"
2555                             + times[i].getTime() + "'");
2556                     ResultSet rs = st.getResultSet();
2557                     assertEquals(1, getCount(rs));
2558                 } catch (SQLException sqle) {
2559                     fail("SQLException is thrown: " + sqle.getMessage());
2560                 } finally {
2561                     try {
2562                         st.close();
2563                     } catch (Exception ee) {
2564                     }
2565                 }
2566             }
2567 
2568             try {
2569                 ps.setTime(2, times[0]);
2570                 fail("SQLException is not thrown");
2571             } catch (Exception sqle) {
2572                 // expected index out of bounds
2573             }
2574 
2575             ps.close();
2576 
2577             try {
2578                 ps.setTime(1, times[0]);
2579                 fail("SQLException is not thrown");
2580             } catch (SQLException sqle) {
2581                 // expected
2582             }
2583             String query1 = "insert into type (Tint) values (?)";
2584             ps1 = conn.prepareStatement(query1);
2585 
2586             try {
2587                 ps1.setTime(1, times[0]);
2588                 ps1.execute();
2589 
2590             } catch (SQLException sqle) {
2591                 fail("SQLException is thrown: " + sqle.toString());
2592             }
2593         } catch (SQLException e) {
2594             fail("SQLException is thrown: " + e.getMessage());
2595         } finally {
2596             try {
2597 
2598                 ps.close();
2599                 ps1.close();
2600             } catch (Exception ee) {
2601             }
2602         }
2603     }
2604 
2605     /**
2606      * @test java.sql.PreparedStatement#setTime(int parameterIndex, Time x,
2607      *       Calendar cal)
2608      */
2609     @TestTargetNew(
2610         level = TestLevel.COMPLETE,
2611         notes = "",
2612         method = "setTime",
2613         args = {int.class, java.sql.Time.class, java.util.Calendar.class}
2614     )
2615     @KnownFailure("preparedStatement.execute() does not return False on update.")
testSetTime_int_Time_Calendar()2616     public void testSetTime_int_Time_Calendar() {
2617 
2618         Calendar[] cals = { Calendar.getInstance(),
2619                 Calendar.getInstance(Locale.GERMANY),
2620                 Calendar.getInstance(TimeZone.getDefault()) };
2621 
2622         Time[] times = { new Time(24, 25, 26), new Time(Integer.MAX_VALUE),
2623                 new Time(123456789) };
2624 
2625 
2626         PreparedStatement ps = null;
2627         PreparedStatement ps1 = null;
2628         try {
2629             String query = "insert into type (timeVal) values (?);";
2630             ps = conn.prepareStatement(query);
2631             Statement st = null;
2632             for (int i = 0; i < times.length; i++) {
2633                 try {
2634                     ps.setTime(1, times[i], cals[i]);
2635                     assertFalse(ps.execute());
2636                     assertTrue(ps.getUpdateCount() > 0);
2637                 } catch (SQLException sqle) {
2638                     fail("SQLException is thrown: " + sqle.getMessage());
2639                 } finally {
2640                     try {
2641                         st.close();
2642                     } catch (Exception ee) {
2643                     }
2644                 }
2645             }
2646 
2647             try {
2648                 ps.setTime(2, times[0], cals[0]);
2649                 fail("SQLException is not thrown");
2650             } catch (Exception sqle) {
2651                 // expected
2652             }
2653 
2654             ps.close();
2655 
2656             try {
2657                 ps.setTime(-2, times[0], cals[1]);
2658                 fail("SQLException is not thrown");
2659             } catch (Exception sqle) {
2660                 // expected
2661             }
2662             String query1 = "insert into type (Tint) values (?);";
2663             ps1 = conn.prepareStatement(query1);
2664 
2665             try {
2666                 ps1.setTime(1, times[0], cals[2]);
2667                 ps1.execute();
2668 
2669             } catch (SQLException sqle) {
2670                 fail("SQLException is thrown: " + sqle.toString());
2671             }
2672         } catch (SQLException e) {
2673             fail("SQLException is thrown: " + e.getMessage());
2674         } finally {
2675             try {
2676 
2677                 ps.close();
2678                 ps1.close();
2679             } catch (Exception ee) {
2680             }
2681         }
2682     }
2683 
2684     /**
2685      * @test java.sql.PreparedStatement#setTimestamp(int parameterIndex,
2686      *       Timestamp x)
2687      */
2688     @TestTargetNew(
2689         level = TestLevel.COMPLETE,
2690         notes = "",
2691         method = "setTimestamp",
2692         args = {int.class, java.sql.Timestamp.class}
2693     )
2694     @KnownFailure("preparedStatement.execute() does not return false on update.")
testSetTimestamp_int_Timestamp()2695     public void testSetTimestamp_int_Timestamp() {
2696 
2697         Timestamp[] timestamps = { new Timestamp(2007, 10, 17, 19, 06, 50, 23),
2698                 new Timestamp(123) };
2699 
2700 
2701         PreparedStatement ps = null;
2702         PreparedStatement ps1 = null;
2703         try {
2704             String query = "insert into type (TS) values (?);";
2705             ps = conn.prepareStatement(query);
2706 
2707             for (int i = 0; i < timestamps.length; i++) {
2708                 try {
2709                     ps.setTimestamp(1, timestamps[i]);
2710                     assertFalse(ps.execute());
2711                     assertTrue(ps.getUpdateCount() > 0);
2712                 } catch (SQLException sqle) {
2713                     fail("SQLException is thrown: " + sqle.getMessage());
2714                 }
2715             }
2716 
2717             try {
2718                 ps.setTimestamp(2, timestamps[0]);
2719                 fail("SQLException is not thrown");
2720             } catch (Exception sqle) {
2721                 // expected
2722             }
2723 
2724             try {
2725                 ps.setTimestamp(-2, timestamps[0]);
2726                 fail("SQLException is not thrown");
2727             } catch (Exception sqle) {
2728                 // expected
2729             }
2730             String query1 = "insert into type (Tint) values (?);";
2731             ps1 = conn.prepareStatement(query1);
2732 
2733             try {
2734                 ps1.setTimestamp(1, timestamps[0]);
2735                 ps1.execute();
2736 
2737             } catch (SQLException sqle) {
2738                 fail("SQLException is thrown: " + sqle.toString());
2739             }
2740         } catch (SQLException e) {
2741             fail("SQLException is thrown: " + e.getMessage());
2742         } finally {
2743             try {
2744 
2745                 ps.close();
2746                 ps1.close();
2747             } catch (Exception ee) {
2748             }
2749         }
2750     }
2751 
2752     /**
2753      * @test {@link java.sql.PreparedStatement#setBlob(int, java.sql.Blob)}
2754      */
2755     @TestTargetNew(
2756         level = TestLevel.COMPLETE,
2757         notes = "not supported",
2758         method = "setBlob",
2759         args = {int.class, java.sql.Blob.class}
2760     )
testSetBlob()2761     public void testSetBlob() {
2762         ResultSet res = null;
2763         PreparedStatement ps = null;
2764         Blob mock = new MockBlob();
2765         try {
2766             String neverExecutedQuery = "select TBlob from type;";
2767             ps = conn.prepareStatement(neverExecutedQuery);
2768             ps.setBlob(1,mock);
2769             fail("Exception expected not supported");
2770         } catch (SQLException e) {
2771             //ok
2772         }
2773     }
2774 
2775     /**
2776      * @test {@link java.sql.PreparedStatement#setClob(int, java.sql.Clob)}
2777      */
2778     @TestTargetNew(
2779         level = TestLevel.COMPLETE,
2780         notes = "not supported",
2781         method = "setClob",
2782         args = {int.class, java.sql.Clob.class}
2783     )
testSetClob()2784     public void testSetClob() {
2785         ResultSet res = null;
2786         PreparedStatement ps = null;
2787         Clob mock = new MockClob();
2788         try {
2789             String neverExecutedQuery = "select TBlob from type;";
2790             ps = conn.prepareStatement(neverExecutedQuery);
2791             ps.setClob(1,mock);
2792             fail("Exception expected not supported");
2793         } catch (SQLException e) {
2794             //ok
2795         }
2796     }
2797 
2798     /**
2799      * @test {@link java.sql.PreparedStatement#setTimestamp(int, Timestamp, Calendar)}
2800      *
2801      */
2802     @TestTargetNew(
2803         level = TestLevel.COMPLETE,
2804         notes = "",
2805         method = "setTimestamp",
2806         args = {int.class, java.sql.Timestamp.class, java.util.Calendar.class}
2807     )
2808     @KnownFailure("preparedStatement.execute() does not return false on update.")
testSetTimestampIntTimestampCalendar()2809     public void testSetTimestampIntTimestampCalendar() {
2810         Calendar[] cals = { Calendar.getInstance(),
2811                 Calendar.getInstance(Locale.GERMANY),
2812                 Calendar.getInstance(TimeZone.getDefault()) };
2813 
2814         Timestamp[] timestamps = { new Timestamp(2007, 10, 17, 19, 06, 50, 23),
2815                 new Timestamp(123) };
2816 
2817 
2818         PreparedStatement ps = null;
2819         PreparedStatement ps1 = null;
2820         try {
2821             String query = "insert into type (timeVal) values (?);";
2822             ps = conn.prepareStatement(query);
2823             Statement st = null;
2824             for (int i = 0; i < timestamps.length; i++) {
2825                 try {
2826                     ps.setTimestamp(1, timestamps[i], cals[i]);
2827                     assertFalse(ps.execute());
2828                     assertTrue(ps.getUpdateCount() > 0);
2829                 } catch (SQLException sqle) {
2830                     fail("SQLException is thrown: " + sqle.getMessage());
2831                 } finally {
2832                     try {
2833                         st.close();
2834                     } catch (Exception ee) {
2835                     }
2836                 }
2837             }
2838 
2839             try {
2840                 ps.setTimestamp(2, timestamps[0], cals[0]);
2841                 ps.execute();
2842                 fail("SQLException is not thrown");
2843             } catch (Exception sqle) {
2844                 // expected
2845             }
2846             ps.close();
2847             try {
2848                 ps.setTimestamp(1, timestamps[0], cals[1]);
2849                 ps.execute();
2850                 fail("SQLException is not thrown");
2851             } catch (SQLException sqle) {
2852                 // expected
2853             }
2854             String query1 = "insert into type (Tint) values (?);";
2855             ps1 = conn.prepareStatement(query1);
2856 
2857             try {
2858                 ps1.setTimestamp(1, timestamps[0], cals[2]);
2859                 ps1.execute();
2860 
2861             } catch (SQLException sqle) {
2862                 fail("SQLException is thrown: " + sqle.toString());
2863             }
2864         } catch (SQLException e) {
2865             fail("SQLException is thrown: " + e.getMessage());
2866         } finally {
2867             try {
2868 
2869                 ps.close();
2870                 ps1.close();
2871             } catch (Exception ee) {
2872             }
2873         }
2874     }
2875 
2876     /**
2877      * @test {@link java.sql.PreparedStatement#setURL(int, java.net.URL)}
2878      *
2879      */
2880     @TestTargetNew(
2881         level = TestLevel.COMPLETE,
2882         notes = "not supported",
2883         method = "setURL",
2884         args = {int.class, java.net.URL.class}
2885     )
testSetURL()2886     public void testSetURL() {
2887         ResultSet res = null;
2888         PreparedStatement ps = null;
2889         try {
2890             String query = "insert into type (TText) values (?);";
2891             ps = conn.prepareStatement(query);
2892             ps.setURL(1, new URL("http://www.android.com"));
2893             fail("Exception expected not supported");
2894         } catch (SQLException e) {
2895            //ok
2896         } catch (Exception e) {
2897             fail("Error in test setup "+e.getMessage());
2898             e.printStackTrace();
2899         }
2900 
2901     }
2902 
2903     /**
2904      * @test {@link java.sql.PreparedStatement#setArray(int, java.sql.Array)}
2905      *
2906      */
2907     @TestTargetNew(
2908         level = TestLevel.COMPLETE,
2909         notes = "not supported",
2910         method = "setArray",
2911         args = {int.class, java.sql.Array.class}
2912     )
testSetArray()2913     public void testSetArray() {
2914         ResultSet res = null;
2915         PreparedStatement ps = null;
2916         Array a = new MockArray();
2917         try {
2918             String query = "insert into type (TText) values (?);";
2919             ps = conn.prepareStatement(query);
2920             ps.setArray(1, new MockArray());
2921             fail("Exception expected not supported");
2922         } catch (SQLException e) {
2923             //ok
2924         } catch (Exception e) {
2925             fail("Error in test setup "+e.getMessage());
2926             e.printStackTrace();
2927         }
2928 
2929     }
2930 
2931     /**
2932      * @test {@link java.sql.PreparedStatement#setRef(int, java.sql.Ref)}
2933      *
2934      */
2935     @TestTargetNew(
2936         level = TestLevel.COMPLETE,
2937         notes = "not supported",
2938         method = "setRef",
2939         args = {int.class, java.sql.Ref.class}
2940     )
testSetRef()2941     public void testSetRef() {
2942         ResultSet res = null;
2943         PreparedStatement ps = null;
2944         Ref mock = new MockRef();
2945         try {
2946             String neverExecutedQuery = "select TBlob from type;";
2947             ps = conn.prepareStatement(neverExecutedQuery);
2948             ps.setRef(1,mock);
2949             fail("Exception expected not supported");
2950         } catch (SQLException e) {
2951             //ok
2952         }
2953 
2954     }
2955 
2956     /**
2957      * @test {@link java.sql.PreparedStatement#setUnicodeStream(int, java.io.InputStream, int)}
2958      *
2959      */
2960     @TestTargetNew(
2961         level = TestLevel.COMPLETE,
2962         notes = "not supported",
2963         method = "setUnicodeStream",
2964         args = {int.class, java.io.InputStream.class, int.class}
2965     )
testSetUnicodestream()2966     public void testSetUnicodestream() {
2967         ResultSet res = null;
2968         PreparedStatement ps = null;
2969         try {
2970             String query = "insert into type (TText) values (?);";
2971             ps = conn.prepareStatement(query);
2972             InputStream file = Class.forName(this.getClass().getName())
2973             .getResourceAsStream("/blob.c");
2974             ps.setUnicodeStream(0, file, 100);
2975             fail("Exception expected not supported");
2976         } catch (SQLException e) {
2977             //ok
2978         } catch (Exception e) {
2979             fail("Error in test setup "+e.getMessage());
2980             e.printStackTrace();
2981         }
2982     }
2983 
testSetCharacterSteam()2984     public void testSetCharacterSteam() {
2985         ResultSet res = null;
2986         PreparedStatement ps = null;
2987         try {
2988             String query = "insert into type (TText) values (?);";
2989             ps = conn.prepareStatement(query);
2990             InputStream file = Class.forName(this.getClass().getName())
2991             .getResourceAsStream("/blob.c");
2992             assertNotNull("Error in test setup: file not found",file);
2993             Reader reader = new InputStreamReader(file);
2994             ps.setCharacterStream(1, reader, 100);
2995         } catch (Exception e) {
2996             fail("Error in test setup "+e.getMessage());
2997             e.printStackTrace();
2998         }
2999     }
3000 
3001     /**
3002      * @test {@link java.sql.PreparedStatement#setAsciiStream(int, InputStream, int)}
3003      *
3004      */
3005     @TestTargetNew(
3006         level = TestLevel.COMPLETE,
3007         notes = "not supported",
3008         method = "setAsciiStream",
3009         args = {int.class, java.io.InputStream.class, int.class}
3010     )
testSetAxciiStream()3011     public void testSetAxciiStream() {
3012         ResultSet res = null;
3013         PreparedStatement ps = null;
3014         try {
3015             String query = "insert into type (TText) values (?);";
3016             ps = conn.prepareStatement(query);
3017             InputStream file = Class.forName(this.getClass().getName())
3018             .getResourceAsStream("/blob.c");
3019             ps.setAsciiStream(0, file, 100);
3020             fail("Exception expected not supported");
3021         } catch (SQLException e) {
3022             // ok
3023         } catch (Exception e) {
3024             fail("Error in test setup "+e.getMessage());
3025             e.printStackTrace();
3026         }
3027     }
3028 
3029     /**
3030      * @test {@link java.sql.PreparedStatement#setBinaryStream(int, InputStream, int)}
3031      *
3032      */
3033     @TestTargetNew(
3034         level = TestLevel.COMPLETE,
3035         notes = "not supported",
3036         method = "setBinaryStream",
3037         args = {int.class, java.io.InputStream.class, int.class}
3038     )
testSetBinaryStream()3039     public void testSetBinaryStream() {
3040 
3041         ResultSet res = null;
3042         PreparedStatement ps = null;
3043         try {
3044             String query = "insert into type (TText) values (?);";
3045             ps = conn.prepareStatement(query);
3046             InputStream file = Class.forName(this.getClass().getName())
3047             .getResourceAsStream("/blob.c");
3048             ps.setBinaryStream(0, file, 100);
3049             fail("Exception expected not supported");
3050         } catch (SQLException e) {
3051             // ok
3052         } catch (Exception e) {
3053             fail("Error in test setup "+e.getMessage());
3054             e.printStackTrace();
3055         }
3056     }
3057 
3058     private class MockRef implements Ref {
3059 
getBaseTypeName()3060         public String getBaseTypeName() throws SQLException {
3061             // TODO Auto-generated method stub
3062             return null;
3063         }
3064 
getObject()3065         public Object getObject() throws SQLException {
3066             // TODO Auto-generated method stub
3067             return null;
3068         }
3069 
getObject(Map<String, Class<?>> map)3070         public Object getObject(Map<String, Class<?>> map) throws SQLException {
3071             // TODO Auto-generated method stub
3072             return null;
3073         }
3074 
setObject(Object value)3075         public void setObject(Object value) throws SQLException {
3076             // TODO Auto-generated method stub
3077 
3078         }
3079 
3080     }
3081 
3082     private class MockArray implements Array {
3083 
getArray()3084         public Object getArray() throws SQLException {
3085             // TODO Auto-generated method stub
3086             return null;
3087         }
3088 
getArray(long index, int count)3089         public Object getArray(long index, int count) throws SQLException {
3090             // TODO Auto-generated method stub
3091             return null;
3092         }
3093 
getArray(long index, int count, Map<String, Class<?>> map)3094         public Object getArray(long index, int count, Map<String, Class<?>> map)
3095                 throws SQLException {
3096             // TODO Auto-generated method stub
3097             return null;
3098         }
3099 
getArray(Map<String, Class<?>> map)3100         public Object getArray(Map<String, Class<?>> map) throws SQLException {
3101             // TODO Auto-generated method stub
3102             return null;
3103         }
3104 
getBaseType()3105         public int getBaseType() throws SQLException {
3106             // TODO Auto-generated method stub
3107             return 0;
3108         }
3109 
getBaseTypeName()3110         public String getBaseTypeName() throws SQLException {
3111             // TODO Auto-generated method stub
3112             return null;
3113         }
3114 
getResultSet()3115         public ResultSet getResultSet() throws SQLException {
3116             // TODO Auto-generated method stub
3117             return null;
3118         }
3119 
getResultSet(long index, int count)3120         public ResultSet getResultSet(long index, int count)
3121                 throws SQLException {
3122             // TODO Auto-generated method stub
3123             return null;
3124         }
3125 
getResultSet(long index, int count, Map<String, Class<?>> map)3126         public ResultSet getResultSet(long index, int count,
3127                 Map<String, Class<?>> map) throws SQLException {
3128             // TODO Auto-generated method stub
3129             return null;
3130         }
3131 
getResultSet(Map<String, Class<?>> map)3132         public ResultSet getResultSet(Map<String, Class<?>> map)
3133                 throws SQLException {
3134             // TODO Auto-generated method stub
3135             return null;
3136         }
3137 
free()3138         public void free() throws SQLException {}
3139     }
3140 
3141     private class MockBlob implements Blob {
3142 
getBinaryStream()3143         public InputStream getBinaryStream() throws SQLException {
3144             // TODO Auto-generated method stub
3145             return null;
3146         }
3147 
getBytes(long pos, int length)3148         public byte[] getBytes(long pos, int length) throws SQLException {
3149             // TODO Auto-generated method stub
3150             return null;
3151         }
3152 
length()3153         public long length() throws SQLException {
3154             // TODO Auto-generated method stub
3155             return 0;
3156         }
3157 
position(Blob pattern, long start)3158         public long position(Blob pattern, long start) throws SQLException {
3159             // TODO Auto-generated method stub
3160             return 0;
3161         }
3162 
position(byte[] pattern, long start)3163         public long position(byte[] pattern, long start) throws SQLException {
3164             // TODO Auto-generated method stub
3165             return 0;
3166         }
3167 
setBinaryStream(long pos)3168         public OutputStream setBinaryStream(long pos) throws SQLException {
3169             // TODO Auto-generated method stub
3170             return null;
3171         }
3172 
setBytes(long pos, byte[] theBytes)3173         public int setBytes(long pos, byte[] theBytes) throws SQLException {
3174             // TODO Auto-generated method stub
3175             return 0;
3176         }
3177 
setBytes(long pos, byte[] theBytes, int offset, int len)3178         public int setBytes(long pos, byte[] theBytes, int offset, int len)
3179                 throws SQLException {
3180             // TODO Auto-generated method stub
3181             return 0;
3182         }
3183 
truncate(long len)3184         public void truncate(long len) throws SQLException {
3185             // TODO Auto-generated method stub
3186 
3187         }
3188 
free()3189         public void free() throws SQLException {}
3190 
getBinaryStream(long pos, long length)3191         public InputStream getBinaryStream(long pos, long length) throws SQLException {
3192             return null;
3193         }
3194     }
3195 
3196     private class MockClob implements Clob {
3197 
getAsciiStream()3198         public InputStream getAsciiStream() throws SQLException {
3199             // TODO Auto-generated method stub
3200             return null;
3201         }
3202 
getCharacterStream()3203         public Reader getCharacterStream() throws SQLException {
3204             // TODO Auto-generated method stub
3205             return null;
3206         }
3207 
getSubString(long pos, int length)3208         public String getSubString(long pos, int length) throws SQLException {
3209             // TODO Auto-generated method stub
3210             return null;
3211         }
3212 
length()3213         public long length() throws SQLException {
3214             // TODO Auto-generated method stub
3215             return 0;
3216         }
3217 
position(Clob searchstr, long start)3218         public long position(Clob searchstr, long start) throws SQLException {
3219             // TODO Auto-generated method stub
3220             return 0;
3221         }
3222 
position(String searchstr, long start)3223         public long position(String searchstr, long start) throws SQLException {
3224             // TODO Auto-generated method stub
3225             return 0;
3226         }
3227 
setAsciiStream(long pos)3228         public OutputStream setAsciiStream(long pos) throws SQLException {
3229             // TODO Auto-generated method stub
3230             return null;
3231         }
3232 
setCharacterStream(long pos)3233         public Writer setCharacterStream(long pos) throws SQLException {
3234             // TODO Auto-generated method stub
3235             return null;
3236         }
3237 
setString(long pos, String str)3238         public int setString(long pos, String str) throws SQLException {
3239             // TODO Auto-generated method stub
3240             return 0;
3241         }
3242 
setString(long pos, String str, int offset, int len)3243         public int setString(long pos, String str, int offset, int len)
3244                 throws SQLException {
3245             // TODO Auto-generated method stub
3246             return 0;
3247         }
3248 
truncate(long len)3249         public void truncate(long len) throws SQLException {
3250             // TODO Auto-generated method stub
3251 
3252         }
3253 
free()3254         public void free() throws SQLException {}
3255 
getCharacterStream(long pos, long length)3256         public Reader getCharacterStream(long pos, long length) throws SQLException {
3257             return null;
3258         }
3259     }
3260 }
3261