File: CallableTest.java

package info (click to toggle)
derby 10.14.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 78,896 kB
  • sloc: java: 691,930; sql: 42,686; xml: 20,511; sh: 3,373; sed: 96; makefile: 60
file content (2073 lines) | stat: -rw-r--r-- 74,194 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
/*
   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbcapi.CallableTest
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
  
     http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
 */

package org.apache.derbyTesting.functionTests.tests.jdbcapi;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.BatchUpdateException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;   // Used by testUpdateLongBinaryProc
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import junit.framework.Test;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.BaseTestSuite;
import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
import org.apache.derbyTesting.junit.JDBC;
import org.apache.derbyTesting.junit.TestConfiguration;

/**
 * Test the CallableStatement interface. 
 * <p>
 * This test converts the old derbynet/callable.java test to JUnit. It 
 * exercises the CallableStatement interface with various combinations of
 *
 *   IN, OUT and INOUT registered parameters,
 *   SQL functions and procedures, and
 *   different data types.
 */
public class CallableTest extends BaseJDBCTestCase {

    /**
     * Routines that should be created before the tests are run and
     * dropped when the tests have finished. 
     */
    private static final String[] ROUTINES = {
       
        "CREATE PROCEDURE TWO_IN_ONE_OUT_PROC " +
        "(IN P1 INT, IN P2 INT, OUT P3 INT) " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".twoInOneOutProc'",

        "CREATE FUNCTION ONE_IN_ONE_OUT_FUNC (P1 INT) RETURNS INT " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".oneInOneOutFunc'",

        "CREATE FUNCTION NO_IN_ONE_OUT_FUNC() RETURNS INT " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".noInOneOutFunc'",

        "CREATE PROCEDURE SYSTEM_OUT_PRINTLN_PROC() " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".systemOutPrintlnProc'",

        "CREATE PROCEDURE UPDATE_LONGVARBINARY_PROC " +
        "(P1 VARCHAR(10000) FOR BIT DATA) MODIFIES SQL DATA " +
        "LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".updateLongVarbinaryProc'",

        "CREATE PROCEDURE NUMERIC_BOUNDARIES_PROC " +
        "(OUT P1 DECIMAL(31,15), OUT P2 DECIMAL(31,15), " +
        "OUT P3 DECIMAL(31,15)) " +
        "READS SQL DATA LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".numericBoundariesProc'",

        "CREATE PROCEDURE NUMERIC_TYPES_IN_AND_OUT_PROC " +
        "(IN P1 SMALLINT, IN P2 INT, IN P3 BIGINT, " +
        "IN P4 REAL, IN P5 DOUBLE, IN P6 DECIMAL(6,3), " +
        "OUT O1 SMALLINT, OUT O2 INT, OUT O3 BIGINT, " +
        "OUT O4 REAL, OUT O5 DOUBLE, OUT O6 DECIMAL(6,3) ) " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".manyTypesInAndOutProc'",

        "CREATE PROCEDURE NON_NUMERIC_TYPES_IN_AND_OUT_PROC " +
        "(IN P1 DATE, IN P2 TIME, IN P3 TIMESTAMP, " +
        "IN P4 VARCHAR(20) FOR BIT DATA, " +
        "OUT O1 DATE, OUT O2 TIME, OUT O3 TIMESTAMP, " +
        "OUT O4 VARCHAR(20) FOR BIT DATA) " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".manyTypesInAndOutProc'",

        "CREATE PROCEDURE MANY_TYPES_INOUT_PROC " +
        "(IN P1 SMALLINT, INOUT P2 SMALLINT, IN P3 INT, INOUT P4 INT, " +
        "IN P5 BIGINT, INOUT P6 BIGINT, IN P7 REAL, INOUT P8 REAL, " +
        "IN P9 DOUBLE, INOUT P10 DOUBLE, IN P11 TIME, INOUT P12 TIME) " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".manyTypesInoutProc'",

        "CREATE PROCEDURE BIGDECIMAL_IN_AND_OUT_PROC " +
        "(IN P1 DECIMAL(14,4), OUT P2 DECIMAL(14,4), " +
        "IN P3 DECIMAL(14,4), OUT P4 DECIMAL(14,4), " +
        "OUT P5 DECIMAL(14,4), OUT P6 DECIMAL(14,4), " +
        "OUT P7 DECIMAL(14,4), OUT P8 DECIMAL(14,4), " +
        "OUT P9 DECIMAL(14,4)) EXTERNAL NAME '" + 
        CallableTest.class.getName() + ".bigDecimalInAndOutProc' " +
        "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA",

        "CREATE PROCEDURE BATCH_UPDATE_PROC " +
        "(P1 INT, P2 INT) MODIFIES SQL DATA " +
        "LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" +
        CallableTest.class.getName() + ".batchUpdateProc'"
    };

    /**
     * Tables that should be created before the tests are run and
     * dropped when the tests have finished. The first element in each row
     * is the name of the table and the second element is the SQL text that
     * creates it.
     */
    private static final String[][] TABLES = {
        // LONGVARBINARY_TABLE is used by UPDATE_LONGVARBINARY_PROC
        { "LONGVARBINARY_TABLE", 
          "CREATE TABLE LONGVARBINARY_TABLE (lvbc Long varchar for bit data)" },

        // NUMERIC_BOUNDARIES_TABLE is used by NUMERIC_BOUNDARIES_PROC
        { "NUMERIC_BOUNDARIES_TABLE", 
          "CREATE TABLE NUMERIC_BOUNDARIES_TABLE " +
          "(maxcol NUMERIC(31,15), mincol NUMERIC(15,15), nulcol NUMERIC)"},

        // BATCH_UPDATE is used by BATCH_UPDATE_PROC
        { "BATCH_TABLE", 
          "CREATE TABLE BATCH_TABLE " +
          "(id int, tag varchar(32), " +
          "idval int constraint idval_ck check (idval >= 0))"},
    };

    /**
     * Creates a new <code>CallableTest</code> instance.
     *
     * @param name name of the test
     */
    public CallableTest(String name) {
        super(name);
    }

    public static Test suite() {
        BaseTestSuite suite = new BaseTestSuite("CallableTest");

        suite.addTest(baseSuite("CallableTest:embedded"));

        suite.addTest(TestConfiguration.clientServerDecorator(
            baseSuite("CallableTest:client")));

        // Test with ConnectionPoolDataSource on client in order to exercise
        // LogicalCallableStatement (DERBY-5871).
        suite.addTest(TestConfiguration.clientServerDecorator(
            TestConfiguration.connectionCPDecorator(
                baseSuite("CallableTest:logical"))));

        // Test with XADataSource on embedded in order to exercise
        // BrokeredCallableStatement (DERBY-5854).
        suite.addTest(TestConfiguration.connectionXADecorator(
            baseSuite("CallableTest:brokered")));

        return suite;
    }

    private static Test baseSuite(String name) {

        BaseTestSuite suite = new BaseTestSuite(name);

        // Add tests that every JVM should be able to run.
        suite.addTestSuite(CallableTest.class);

        // Add tests that require JDBC 3 
        if (JDBC.vmSupportsJDBC3()) {

            // Tests that require DriverManager.
            suite.addTest
                (new CallableTest("xtestUpdateLongBinaryProc"));

            // Tests that require DriverManager and batch update.
            suite.addTest
                (new CallableTest("xtestBatchUpdate"));
            suite.addTest
                (new CallableTest("xtestBatchUpdateError"));

            // Tests that get/set BigDecimal
            suite.addTest
                (new CallableTest("xtestBigDecimalInAndOutProc"));
            suite.addTest
                (new CallableTest("xtestNumericTypesInAndOutProc"));

            // Test that both requires DriverManager and BigDecimal
            suite.addTest
                (new CallableTest("xtestNumericBoundariesProc"));
        }


        return new CleanDatabaseTestSetup(suite) 
        {
            /**
            * Creates the tables and the stored procedures used in the test
            * cases.
            * @throws SQLException 
            */
            protected void decorateSQL(Statement s) throws SQLException
            {
                for (int i = 0; i < ROUTINES.length; i++) {
                    s.execute(ROUTINES[i]);
                }
                for (int i = 0; i < TABLES.length; i++) {
                    s.execute(TABLES[i][1]);
                }
            }
        };
    } // End baseSuite

    /**
     * Sets up the connection for a test case and clears all tables
     * used in the test cases.
     * @throws SQLException 
     */
    public void setUp() throws SQLException
    {
        Connection conn = getConnection();
        conn.setAutoCommit(false);
        Statement s = createStatement();
        for (int i = 0; i < TABLES.length; i++) {
            s.execute("DELETE FROM " + TABLES[i][0]);
        }
        s.close();
        conn.commit();
    }

    // TESTS

    /**
     * Calls a SQL procedure with two input parameters and one output.
     * @throws SQLException 
     */
    public void testTwoInOneOutProc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
        cs.setInt(1, 6);
        cs.setInt(2, 9);
        cs.registerOutParameter (3, java.sql.Types.INTEGER);
        cs.execute();
        assertEquals("Sum of 6 and 9", 15, cs.getInt(3));

    }

    /**
     * Calls a SQL function with one input parameter and one output.
     * @throws SQLException 
     */
    public void testOneInOneOutFunc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("? = call ONE_IN_ONE_OUT_FUNC (?)");
        cs.registerOutParameter (1, java.sql.Types.INTEGER);
        cs.setInt(2, 6);
        cs.execute();
        assertEquals("Square of 6 then plus 6", 42, cs.getInt(1));
    }

    /**
     * Calls a SQL function that takes no input parameter and returns one 
     * output.
     * @throws SQLException 
     */
    public void testNoInOneOutFunc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("? = call NO_IN_ONE_OUT_FUNC()");
        cs.registerOutParameter (1, java.sql.Types.INTEGER);
        cs.execute();
        assertEquals("NO_IN_ONE_OUT_FUNC output value", 55, cs.getInt(1));

    }

    public void testIsolationLevelChangeAfterFunctionCall()
            throws SQLException {
        CallableStatement cs = prepareCall("? = CALL NO_IN_ONE_OUT_FUNC()");
        cs.registerOutParameter(1, java.sql.Types.INTEGER);
        cs.execute();
        assertEquals(55, cs.getInt(1));
        getConnection().setTransactionIsolation(
            Connection.TRANSACTION_SERIALIZABLE);
    }

    /**
     * Calls a SQL procedure that outputs a message with System.out.println.
     * Converted from the original test, but initially disabled because of the
     * message output to system out. Easily enabled by changing method name to
     * remove the initial "norun_" (the name becomes testSystemOutPrintlnProc).
     * @throws SQLException 
     */
    public void norun_testSystemOutPrintlnProc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("call SYSTEM_OUT_PRINTLN_PROC()");
        cs.execute();
        cs.close();
    }

    /**
     * Calls a SQL procedure that takes numeric IN and OUT parameters.
     * Excluded from JSR169/j2ME, which doesn't support get/set BigDecimal yet.
     * @throws SQLException 
     */
    public void xtestNumericTypesInAndOutProc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");

        cs.setShort(1, (short) 3);
        cs.setInt(2, 4);
        cs.setLong(3, 5);
        cs.setFloat(4, (float) 6.0);
        cs.setDouble(5, 7.0);
        cs.setBigDecimal(6, new BigDecimal("88.88"));

        cs.registerOutParameter (7, java.sql.Types.SMALLINT);
        cs.registerOutParameter (8, java.sql.Types.INTEGER);
        cs.registerOutParameter (9, java.sql.Types.BIGINT);
        cs.registerOutParameter (10, java.sql.Types.REAL);
        cs.registerOutParameter (11, java.sql.Types.DOUBLE);
        cs.registerOutParameter (12, java.sql.Types.DECIMAL);

        cs.execute();

        assertEquals("OUT short", (short) 3, cs.getShort(7));
        assertEquals("OUT int"  , 4, cs.getInt(8));
        assertEquals("OUT long" , 5, cs.getLong(9));
        assertEquals("OUT float" , (float) 6.0, cs.getFloat(10), .0001);
        assertEquals("OUT double" , 7.0, cs.getDouble(11), .0001);
        assertDecimalSameValue("OUT decimal", "88.88", cs.getBigDecimal(12));

        // test that setObject() does the right thing for BigDecimal. see derby-5488.
        cs.setObject(3, new BigDecimal( "10" ) );
        cs.execute();
        assertEquals("OUT long" , 10, cs.getLong(9));

        // test that setObject() does the right thing for BigInteger. see derby-5488.
        cs.setObject(3, new BigInteger( "11" ) );
        cs.execute();
        assertEquals("OUT long" , 11, cs.getLong(9));
    }

    /**
     * Calls a SQL procedure that takes non-numeric IN and OUT parameters.
     * @throws SQLException 
     */
    public void testNonNumericTypesInAndOutProc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");

        cs.setDate(1, Date.valueOf("2002-05-12"));
        cs.setTime(2, Time.valueOf("10:05:02"));
        cs.setTimestamp(3, Timestamp.valueOf("2002-05-12 10:05:02.000000000"));
        byte[] ba = new byte[2];
        ba[0] = 1;
        ba[1] = 2;
        cs.setBytes(4, ba);

        cs.registerOutParameter (5, java.sql.Types.DATE);
        cs.registerOutParameter (6, java.sql.Types.TIME);
        cs.registerOutParameter (7, java.sql.Types.TIMESTAMP);
        cs.registerOutParameter (8, java.sql.Types.VARBINARY);

        cs.execute();

        assertEquals("OUT date", Date.valueOf("2002-05-12"), cs.getDate(5));
        assertEquals("OUT time"  , Time.valueOf("10:05:02"), cs.getTime(6));
        assertEquals("OUT timestamp" , 
            Timestamp.valueOf("2002-05-12 10:05:02.000000000"), 
            cs.getTimestamp(7));
        assertTrue(Arrays.equals(ba, cs.getBytes(8)));
    }

    /**
     * Test that the getters and setters for Date, Time and Timestamp work as
     * expected when given a Calendar argument. Test case for DERBY-4615.
     */
    public void testTimeAndDateWithCalendar() throws SQLException {
        // Create calendars for some time zones to use when testing the
        // setter methods.
        Calendar[] cal1 = {
            Calendar.getInstance(), // local calendar
            Calendar.getInstance(TimeZone.getTimeZone("GMT")),
            Calendar.getInstance(TimeZone.getTimeZone("Europe/Oslo")),
            Calendar.getInstance(TimeZone.getTimeZone("Asia/Hong_Kong")),
        };

        // Use calendars for the same time zones in the getters, but create
        // clones so that we don't get interference between the calendars.
        Calendar[] cal2 = (Calendar[]) cal1.clone();
        for (int i = 0; i < cal2.length; i++) {
            cal2[i] = (Calendar) cal2[i].clone();
        }

        // Now test all the combinations.
        for (int i = 0; i < cal1.length; i++) {
            for (int j = 0; j < cal2.length; j++) {
                testTimeAndDateWithCalendar(cal1[i], cal2[j]);
            }
        }
    }

    /**
     * Private helper for {@link #testTimeAndDateWithCalendar()}. This method
     * calls a procedure that takes Date, Time and Timestamp arguments and
     * returns the exact same values. Call the setters with one calendar and
     * the getters with another calendar, and verify that the expected
     * conversion between time zones has happened.
     *
     * @param cal1 the calendar to use for the setter methods
     * @param cal2 the calendar to use for the getter methods
     */
    private void testTimeAndDateWithCalendar(Calendar cal1, Calendar cal2)
            throws SQLException
    {
        println("Running " + getName() + "() with " +
                cal1.getTimeZone().getDisplayName() + " and " +
                cal2.getTimeZone().getDisplayName());

        CallableStatement cs = prepareCall(
                "call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");

        Date d = Date.valueOf("2010-04-14");
        Time t = Time.valueOf("12:23:24");
        Timestamp ts = new Timestamp(System.currentTimeMillis());
        ts.setNanos(123456789);

        cs.setDate(1, d, cal1);
        cs.setTime(2, t, cal1);
        cs.setTimestamp(3, ts, cal1);
        cs.setNull(4, Types.VARBINARY); // we don't care about VARBINARY here

        cs.registerOutParameter (5, java.sql.Types.DATE);
        cs.registerOutParameter (6, java.sql.Types.TIME);
        cs.registerOutParameter (7, java.sql.Types.TIMESTAMP);
        cs.registerOutParameter (8, java.sql.Types.VARBINARY);

        cs.execute();

        assertSameDate(d, cal1, cs.getDate(5, cal2), cal2);
        assertSameTime(t, cal1, cs.getTime(6, cal2), cal2);
        vetTimestamp(ts, cal1, cs.getTimestamp(7, cal2), cal2);
    }

    /**
     * Assert that two {@code java.util.Date} values have the same
     * representation of their date components (year, month and day) in their
     * respective time zones.
     *
     * @param expected the expected date
     * @param cal1 a calendar representing the time zone of the expected date
     * @param actual the actual date
     * @param cal2 a calendar representing the time zone of the actual date
     */
    private void assertSameDate(java.util.Date expected, Calendar cal1,
                                java.util.Date actual, Calendar cal2) {
        cal1.clear();
        cal1.setTime(expected);
        int expectedYear = cal1.get(Calendar.YEAR);
        int expectedMonth = cal1.get(Calendar.MONTH);
        int expectedDay = cal1.get(Calendar.DAY_OF_MONTH);

        cal2.clear();
        cal2.setTime(actual);
        assertEquals("year", expectedYear, cal2.get(Calendar.YEAR));
        assertEquals("month", expectedMonth, cal2.get(Calendar.MONTH));
        assertEquals("day", expectedDay, cal2.get(Calendar.DAY_OF_MONTH));
    }

    /**
     * Assert that two {@code java.util.Date} values have the same
     * representation of their time components (hour, minute, second) in their
     * respective time zones.
     *
     * @param expected the expected time
     * @param cal1 a calendar representing the time zone of the expected time
     * @param actual the actual time
     * @param cal2 a calendar representing the time zone of the actual time
     */
    private void assertSameTime(java.util.Date expected, Calendar cal1,
                                java.util.Date actual, Calendar cal2) {
        cal1.clear();
        cal1.setTime(expected);
        int expectedHour = cal1.get(Calendar.HOUR_OF_DAY);
        int expectedMinute = cal1.get(Calendar.MINUTE);
        int expectedSecond = cal1.get(Calendar.SECOND);

        cal2.clear();
        cal2.setTime(actual);
        assertEquals("hour", expectedHour, cal2.get(Calendar.HOUR_OF_DAY));
        assertEquals("minute", expectedMinute, cal2.get(Calendar.MINUTE));
        assertEquals("second", expectedSecond, cal2.get(Calendar.SECOND));
    }

    /**
     * Check that a {@code Timestamp} value is as expected when it has been
     * passed to a stored procedure and read back again from that procedure,
     * using different calendars for the {@code setTimestamp()} and
     * {@code getTimestamp()} calls.
     *
     * @param original the original timestamp that was passed to the procedure
     * @param cal1 the calendar object passed to {@code setTimestamp()} before
     * calling the procedure
     * @param returned the timestamp returned from the procedure
     * @param cal2 the calendar object passed to {@code getTimestamp()} when
     * reading the value returned by the procedure
     */
    private void vetTimestamp(Timestamp original, Calendar cal1,
                              Timestamp returned, Calendar cal2) {

        // Initialize cal1 with values from the original timestamp.
        cal1.clear();
        cal1.setTime(original);

        // The stored procedure itself doesn't have any knowledge about the
        // calendar passed to setTimestamp() or getTimestamp(), so it will
        // see the timestamp in the local timezone. Find out what it looks
        // like in this intermediate state.
        Calendar intermediate = Calendar.getInstance();
        intermediate.set(cal1.get(Calendar.YEAR),
                cal1.get(Calendar.MONTH),
                cal1.get(Calendar.DATE),
                cal1.get(Calendar.HOUR_OF_DAY),
                cal1.get(Calendar.MINUTE),
                cal1.get(Calendar.SECOND));

        // The returned timestamp will be based on the values in the
        // intermediate representation, but using the calendar passed to
        // getTimestamp().
        cal2.clear();
        cal2.set(intermediate.get(Calendar.YEAR),
                intermediate.get(Calendar.MONTH),
                intermediate.get(Calendar.DATE),
                intermediate.get(Calendar.HOUR_OF_DAY),
                intermediate.get(Calendar.MINUTE),
                intermediate.get(Calendar.SECOND));

        // Construct a new timestamp with the value we expect to be returned
        // from getTimestamp().
        Timestamp expected = new Timestamp(cal2.getTimeInMillis());
        expected.setNanos(original.getNanos());

        // Compare it with the actually returned value.
        assertEquals(expected, returned);
    }

    /**
     * Calls a SQL procedure that takes INOUT parameters of various types.
     * @throws SQLException 
     */
    public void testManyTypesInoutProc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("call MANY_TYPES_INOUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");

        cs.registerOutParameter (2, java.sql.Types.SMALLINT);
        cs.registerOutParameter (4, java.sql.Types.INTEGER);
        cs.registerOutParameter (6, java.sql.Types.BIGINT);
        cs.registerOutParameter (8, java.sql.Types.REAL);
        cs.registerOutParameter (10, java.sql.Types.DOUBLE);
        cs.registerOutParameter (12, java.sql.Types.TIME);

        cs.setShort(1, (short)6);
        cs.setShort(2, (short)9);
        cs.setInt(3, 6);
        cs.setInt(4, 9);
        cs.setLong(5, (long)99999);
        cs.setLong(6, (long)88888888);
        cs.setFloat(7, (float)6.123453);
        cs.setFloat(8, (float)77777);
        cs.setDouble(9, (double)6.123453);
        cs.setDouble(10, (double)8888888888888.01234);
        cs.setTime(11, Time.valueOf("11:06:03"));
        cs.setTime(12, Time.valueOf("10:05:02"));

        cs.execute();

        assertEquals("Short: Sum of 6 + 9", 15, cs.getShort(2));
        assertEquals("Int: Sum of 6 + 9", 15, cs.getInt(4));
        assertEquals("Long: Sum of 99999 + 88888888", 88988887, cs.getLong(6));
        assertEquals("Float: Sum of 6.123453 and 77777" , (float) 77783.123453,
            cs.getFloat(8), .000001);
        assertEquals("Double: Sum of Sum of 6.987654 and 8888888888888.01234",
            8.888888888894135e12, cs.getDouble(10), .000001);
        assertEquals("Time: changed to", Time.valueOf("11:06:03"), 
            cs.getTime(12));

    }

    /**
     * Calls a SQL procedure that updates a long varbinary column.
     * Uses DriverManager, so this test requires JDBC 2 DriverManager support.
     * @throws SQLException 
     */
    public void xtestUpdateLongBinaryProc() throws SQLException
    {
        // Insert a row with an initial value that will be updated later.
        Statement stmt = createStatement();
        stmt.executeUpdate(
            "INSERT INTO LONGVARBINARY_TABLE VALUES(X'010305')");

        // Build up a byte array that will replace the initial value.
        int bytearrsize = 50;
        byte[] bytearr=new byte[bytearrsize];
        String sbyteval=null;
        for (int count=0;count<bytearrsize;count++)
        {
            sbyteval=Integer.toString(count%255);
            bytearr[count]=Byte.parseByte(sbyteval);
        }

        // Update the value in the database.
        CallableStatement cstmt = prepareCall(
            "CALL UPDATE_LONGVARBINARY_PROC(?)");
        cstmt.setObject(1,bytearr,java.sql.Types.LONGVARBINARY);
        cstmt.executeUpdate();
        
        // Retrieve the updated value and verify it's correct.
        ResultSet rs = stmt.executeQuery(
            "SELECT LVBC FROM LONGVARBINARY_TABLE");
        assertNotNull("SELECT from LONGVARBINARY_TABLE", rs);

        while (rs.next())
        {
            byte[] retvalue = (byte[]) rs.getObject(1);
            assertTrue(Arrays.equals(bytearr, retvalue));
        }
    }

    /**
     * Batches up calls to a SQL procedure that updates a value in a table.
     * Uses DriverManager and Batch calls, so requires JDBC 2 support.
     * @throws SQLException 
     */
    public void xtestBatchUpdate() throws SQLException
    {
        // Setup table data
        Statement stmt = createStatement();
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(1, 'STRING_1',10)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(2, 'STRING_2',0)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(3, 'STRING_3',0)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(4, 'STRING_4a',0)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(4, 'STRING_4b',0)");

        // Setup batch to modify value to 10 * the id (makes verification easy).
        CallableStatement cstmt = prepareCall("CALL BATCH_UPDATE_PROC(?,?)");
        cstmt.setInt(1,2);  // Id 2's value will be updated to 20.
        cstmt.setInt(2,20);
        cstmt.addBatch();
        cstmt.setInt(1,3);  // Id 3's value will be updated to 30.
        cstmt.setInt(2,30);
        cstmt.addBatch();
        cstmt.setInt(1,4);  // Two rows will be updated to 40 for id 4.
        cstmt.setInt(2,40);
        cstmt.addBatch();
        cstmt.setInt(1,5);  // No rows updated (no id 5).
        cstmt.setInt(2,50);
        cstmt.addBatch();

        int[] updateCount=null;
        try {
            updateCount = cstmt.executeBatch();
            assertEquals("updateCount length", 4, updateCount.length);

            for(int i=0; i< updateCount.length; i++){
                if (usingEmbedded()) {
                    assertEquals("Batch updateCount", 0, updateCount[0]);
                }
                else if (usingDerbyNetClient()) {
                    assertEquals("Batch updateCount", -1, updateCount[0]);
                }
            }
        } catch (BatchUpdateException b) {
            assertSQLState("Unexpected SQL State", b.getSQLState(), b);
        }

        // Retrieve the updated values and verify they are correct.
        ResultSet rs = stmt.executeQuery(
            "SELECT id, tag, idval FROM BATCH_TABLE order by id, tag");
        assertNotNull("SELECT from BATCH_TABLE", rs);

        while (rs.next())
        {
            assertEquals(rs.getString(2), rs.getInt(1)*10, rs.getInt(3));
        }
    }


    /**
     * Batches up many calls to a SQL procedure that updates a value in a table.
     * All calls should succeed, except for one that should fail with a check
     * constraint violation.
     * Uses DriverManager and Batch calls, so requires JDBC 2 support.
     * @throws SQLException 
     */
    public void xtestBatchUpdateError() throws SQLException
    {
        // Setup table data
        Statement stmt = createStatement();
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(1, 'STRING_1',0)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(2, 'STRING_2',0)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(3, 'STRING_3',0)");
        stmt.executeUpdate("INSERT INTO BATCH_TABLE VALUES(4, 'STRING_4',0)");

        // Setup batch to modify values.
        CallableStatement cstmt = prepareCall("CALL BATCH_UPDATE_PROC(?,?)");
        cstmt.setInt(1,1);  // Set id 1's value to 10
        cstmt.setInt(2,10);
        cstmt.addBatch();
        cstmt.setInt(1,2);  // Set id 2's value to -5 (should fail)
        cstmt.setInt(2,-5);
        cstmt.addBatch();
        cstmt.setInt(1,3);  // Set id 3's value to 30.
        cstmt.setInt(2,30);
        cstmt.addBatch();
        cstmt.setInt(1,4);  // Set id 4's value to 40.
        cstmt.setInt(2,40);
        cstmt.addBatch();

        int[] updateCount=null;

        try {
            updateCount = cstmt.executeBatch();
            fail("Expected batchExecute to fail");
        } catch (BatchUpdateException b) {

            if (usingEmbedded()) {
                assertSQLState("38000", b.getSQLState(), b);
            }
            else if (usingDerbyNetClient()) {
                assertSQLState("XJ208", b.getSQLState(), b);
            }

            updateCount = b.getUpdateCounts();

            /* The updateCount is different for embedded and client because
             * the embedded driver stops processing the batch after the
             * failure, while the client driver continues processing (see
             * DERBY-2301).
             */
            if (usingEmbedded()) {
                assertEquals("updateCount length", 1, updateCount.length);
                assertEquals("Batch updateCount", 0, updateCount[0]);
            }
            else if (usingDerbyNetClient()) {
                assertEquals("updateCount length", 4, updateCount.length);
                for(int i=0; i< updateCount.length; i++){
                    if(i == 1) // The second command in the batch failed.
                        assertEquals("Batch updateCount", -3, updateCount[i]);
                    else
                        assertEquals("Batch updateCount", -1, updateCount[i]);
                }
            }
        }

        // Make sure the right rows in the table were updated.
        ResultSet rs = stmt.executeQuery(
            "SELECT id, tag, idval FROM BATCH_TABLE order by id, tag");
        assertNotNull("SELECT from BATCH_TABLE", rs);

        while (rs.next())
        {
            /* Embedded and client results should be the same for the first
             * two rows (the changed row for the first successful command in 
             * the batch, followed by the unchanged row for the second command,
             * which failed).
             * After the first two rows, results are different because the
             * rest of the commands in the batch executed for client, but not
             * for embedded.
             */
            switch(rs.getInt(1)) 
            {
                case 1:
                    assertEquals(rs.getString(2), 10, rs.getInt(3));
                    break;
                case 2:
                    assertEquals(rs.getString(2), 0, rs.getInt(3));
                    break;
                default:
                    if (usingEmbedded()) {
                        assertEquals(rs.getString(2), 0, rs.getInt(3));
                    }
                    else if (usingDerbyNetClient()) {
                        assertEquals(rs.getString(2), rs.getInt(1)*10, 
                            rs.getInt(3));
                    }
                    break;
            }
        }
    }

    /**
     * Calls a SQL procedure that populates OUT parameters with minimum, 
     * maximum, and null values fetched from a table with numeric columns. 
     * Pre-history: long, long ago this test was added to exercise a problem
     * with converting BigDecimal to packed decimal, which left the Network 
     * Server cpu bound.
     * Excluded from environments than don't have JDBC 2 DriverManager.
     * Excluded from JSR169/j2ME, which doesn't support get/set BigDecimal yet.
     * @throws SQLException 
     */
    public void xtestNumericBoundariesProc() throws SQLException
    {
        // Populate the test table
        String SqlStatement= 
            "insert into NUMERIC_BOUNDARIES_TABLE " +
            "values(999999999999999, 0.000000000000001, null)";
        Statement stmt = createStatement();
        stmt.executeUpdate(SqlStatement);

        // SELECT the values back by calling the SQL procedure.
        CallableStatement cstmt = prepareCall(
            "CALL NUMERIC_BOUNDARIES_PROC(?,?,?)");
        cstmt.registerOutParameter(1,java.sql.Types.NUMERIC,15);
        cstmt.registerOutParameter(2,java.sql.Types.NUMERIC,15);
        cstmt.registerOutParameter(3,java.sql.Types.NUMERIC,15);

        cstmt.execute();

        assertDecimalSameValue("OUT 1", "999999999999999.000000000000000", 
            cstmt.getBigDecimal(1));
        assertDecimalSameValue("OUT 2", "0.000000000000001", 
            cstmt.getBigDecimal(2));
        assertNull("Expected OUT 3 to be null", cstmt.getBigDecimal(3));

    }

    /**
     * Calls a SQL procedure with BigDecimal IN and OUT parameters.
     * Excluded from JSR169/j2ME, which doesn't support get/set BigDecimal yet.
     * @throws SQLException 
     */
    public void xtestBigDecimalInAndOutProc() throws SQLException
    {
        CallableStatement cs = prepareCall
            ("CALL BIGDECIMAL_IN_AND_OUT_PROC (?, ?, ?, ?, ?, ?, ?, ?, ?)");
        cs.setBigDecimal(1, new BigDecimal("33.333"));
        cs.registerOutParameter (2, java.sql.Types.DECIMAL);
        cs.setBigDecimal(3, new BigDecimal("-999.999999"));
        cs.registerOutParameter (4, java.sql.Types.DECIMAL);
        cs.registerOutParameter (5, java.sql.Types.DECIMAL);
        cs.registerOutParameter (6, java.sql.Types.DECIMAL);
        cs.registerOutParameter (7, java.sql.Types.DECIMAL);
        cs.registerOutParameter (8, java.sql.Types.DECIMAL);
        cs.registerOutParameter (9, java.sql.Types.DECIMAL);
        cs.execute();

        assertDecimalSameValue("OUT 2", "33.3330",        cs.getBigDecimal(2));
        assertDecimalSameValue("OUT 4", "-33332.9966",    cs.getBigDecimal(4));
        assertDecimalSameValue("OUT 5", "-966.6669",      cs.getBigDecimal(5));
        assertDecimalSameValue("OUT 6", "0.0000",         cs.getBigDecimal(6));
        assertDecimalSameValue("OUT 7", "0.0000",         cs.getBigDecimal(7));
        assertDecimalSameValue("OUT 8", "99999999.0000",  cs.getBigDecimal(8));
        assertDecimalSameValue("OUT 9", "-99999999.0000", cs.getBigDecimal(9));
    }

    /**
     * Wrapper for BigDecimal compareTo.
     * Called by the xtestBigDecimalInAndOutProc,
     * xtestNumericTypesInAndOutProc, and
     * xtestNumericBoundariesProc, methods.
     */
    public void assertDecimalSameValue(String message, String expected_s, 
        BigDecimal actual)
    {
        BigDecimal expected = (new BigDecimal(expected_s));
        assertTrue(message + 
            " expected:<" + expected + "> but was:<" + actual.toString() + ">", 
            expected.compareTo(actual)==0);
    }

    // SQL ROUTINES (functions and procedures)

    /** 
     * External code for the ONE_IN_ONE_OUT_FUNC SQL function, which squares 
     * the value of the input arg, then adds the input arg to that result.
     *
     * @param p1 integer input argument to be used in calculation
     */
    public static int oneInOneOutFunc (int p1)
    {
        return (p1 * p1) + p1;
    }

    /**
     * External code for the TWO_IN_ONE_OUT_PROC SQL procedure, which sets the 
     * value of the third arg to the sum of the first two.
     *
     * @param p1 integer input parameter to be used in calculation
     * @param p2 integer input parameter to be used in calculation
     * @param p3 integer output parameter that stores result of the calculation
     */
    public static void twoInOneOutProc (int p1, int p2, int[] p3)
    {
        p3[0] = p1 + p2;
    }

    /**
     * External code for the NO_IN_ONE_OUT_FUNC SQL function, which takes no 
     * parameters and returns the value 55.
     */
    public static int noInOneOutFunc ()
    {
        return 55;
    }

    /**
     * External code for the SYSTEM_OUT_PRINTLN_PROC SQL procedure, which
     * outputs a message to System out.
     */
    public static void systemOutPrintlnProc()
    {
        System.out.println("I'm doing something here...");
    }

    /**
     * External code for the UPDATE_LONGVARBINARY_PROC SQL procedure, which 
     * sets the value of the Long varbinary column in the LONGVARBINARY_TABLE 
     * table given the input parameter.
     *
     * @param in_param input parameter to be used for database update
     * @exception SQLException if a database error occurs
     */
    public static void updateLongVarbinaryProc (byte[] in_param) 
        throws SQLException
    {
        Connection conn = 
            DriverManager.getConnection("jdbc:default:connection");
        PreparedStatement ps = 
            conn.prepareStatement("update LONGVARBINARY_TABLE set lvbc=?");

        ps.setBytes(1,in_param);
        ps.executeUpdate();

        ps.close();
        conn.close();
    } 

    /**
     * External code for the NUMERIC_BOUNDARIES_PROC SQL procedure, which 
     * fetches max, min, and null values from a table with numeric columns.
     *
     * @param param1 output parameter that returns maxcol value
     * @param param2 output parameter that returns mincol value
     * @param param3 output parameter that returns nulcol value
     * @exception SQLException if a database error occurs
     */
    public static void numericBoundariesProc (BigDecimal[] param1,
        BigDecimal[] param2, BigDecimal[] param3) throws SQLException
    {
        Connection conn = 
            DriverManager.getConnection("jdbc:default:connection");
        Statement stmt = conn.createStatement();

        ResultSet rs = stmt.executeQuery
            ("select maxcol, mincol, nulcol from NUMERIC_BOUNDARIES_TABLE");

        if (rs.next())
        {
            param1[0]=rs.getBigDecimal(1);
            param2[0]=rs.getBigDecimal(2);
            param3[0]=rs.getBigDecimal(3);
        }
        else
        {
            throw new SQLException("Data not found");
        }

        rs.close();
        stmt.close();
        conn.close();
    } 


    /**
     * External code for the BIGDECIMAL_IN_AND_OUT_PROC SQL procedure, which
     * tests INT and OUT parameters with the BigDecimal data type.
     *
     * @param bd1   input parameter
     * @param bdr1  output parameter set to bd1 * bd2
     * @param bd2   input parameter
     * @param bdr2  output parameter set to bd1 + bd2
     * @param bdr3  output parameter set to a fixed value
     * @param bdr4  output parameter set to a fixed value
     * @param bdr5  output parameter set to a fixed value
     * @param bdr6  output parameter set to a fixed value
     * @param bdr7  output parameter set to a fixed value
     *
     */
    public static void bigDecimalInAndOutProc (BigDecimal bd1, 
        BigDecimal bdr1[], BigDecimal bd2, BigDecimal bdr2[], 
        BigDecimal bdr3[], BigDecimal bdr4[], BigDecimal bdr5[], 
        BigDecimal bdr6[], BigDecimal bdr7[])
    {
        bdr1[0] = bd1;
        bdr2[0] = bd1.multiply(bd2);
        bdr3[0] = bd1.add(bd2);
        bdr4[0] = new BigDecimal(".00000");
        bdr5[0] = new BigDecimal("-.00000");
        bdr6[0] = new BigDecimal("99999999.");
        bdr7[0] = new BigDecimal("-99999999.");
    }

    /**
     * External code for the NUMERIC_TYPES_IN_AND_OUT_PROC SQL procedure, 
     * which tests IN and OUT parameters with many numeric types.
     * Also tests method overload for manyTypesInAndOutProc.
     *
     * @param s     short      input parameter
     * @param i     int        input parameter
     * @param l     long       input parameter
     * @param f     float      input parameter
     * @param d     double     input parameter
     * @param bd    BigDecimal input parameter
     * @param sr    short      output parameter
     * @param ir    int        output parameter
     * @param lr    long       output parameter
     * @param fr    float      output parameter
     * @param dr    double     output parameter
     * @param bdr   BigDecimal output parameter
     *
     */
    public static void manyTypesInAndOutProc (
        short s,    int i,    long l,   float f,   double d,   BigDecimal bd, 
        short[] sr, int[] ir, long[] lr,float[] fr,double[] dr,BigDecimal[] bdr
    )
    {
        sr[0] = s;
        ir[0] = i;
        lr[0] = l;
        fr[0] = f;
        dr[0] = d;
        bdr[0] = bd;
    }

    /**
     * External code for the NON_NUMERIC_TYPES_IN_AND_OUT_PROC SQL procedure,
     * which tests IN / OUT parameters with many non-numeric types.
     * Also tests method overload for manyTypesInAndOutProc.
     *
     * @param dt    date       input parameter
     * @param t     time       input parameter
     * @param ts    timestamp  input parameter
     * @param ba    byte       input parameter
     * @param dtr   date       output parameter
     * @param tr    time       output parameter
     * @param tsr   timestamp  output parameter
     * @param bar   byte       output parameter
     *
     */
    public static void manyTypesInAndOutProc (
        Date dt,    Time t,    Timestamp ts,    byte[] ba,
        Date[] dtr, Time[] tr, Timestamp[] tsr, byte[][] bar
    )
    {
        dtr[0] = dt;
        tr[0] = t;
        tsr[0] = ts;
        bar[0] = ba;
    }

    /**
     * External code for the MANY_TYPES_INOUT_PROC SQL procedure, which tests 
     * INOUT parameters with many types.
     *
     * @param s1    short  input parameter
     * @param s2    short  output parameter
     * @param p1    int    input parameter
     * @param p2    int    output parameter
     * @param l1    long   input parameter
     * @param l2    long   output parameter
     * @param f1    float  input parameter
     * @param f2    float  output parameter
     * @param d1    double input parameter
     * @param d2    double output parameter
     * @param t1    time   input parameter
     * @param t2    time   output parameter
     */
    public static void manyTypesInoutProc (
        short s1, short s2[], int p1, int p2[], long l1, long l2[],
        float f1, float f2[], double d1, double d2[], Time t1, Time t2[]
    )
    {
        p2[0] = p1 + p2[0];
        s2[0] = (short) (s1 + s2[0]);
        l2[0] = l1 + l2[0];
        f2[0] = f1 + f2[0];
        d2[0] = d1 + d2[0];
        t2[0] = t1;
    }

    /**
     * External code for the BATCH_UPDATE_PROC SQL procedure, which updates 
     * data in a table for a given id.
     * Called by xtestBatchUpdateProc.
     *
     * @param id Id to be updated
     * @param id_newval New value to which the id should be updated
     * @exception SQLException if a database error occurs
     */
    public static void batchUpdateProc (int id, int id_newval)
        throws SQLException
    {
        Connection conn = 
            DriverManager.getConnection("jdbc:default:connection");
        PreparedStatement ps = conn.prepareStatement
            ("update BATCH_TABLE set idval=? where id=?");

        ps.setInt(1, id_newval);
        ps.setInt(2, id);
        ps.executeUpdate();
        ps.close();
        conn.close();
    }
    
      
//jdbc 3.0 test methods
    
    public void testsetURL() throws SQLException, MalformedURLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		URL domain = new URL("http://www.apache.org");
    	    cs.setURL("URL",domain);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNull() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setNull("P1",1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetBoolean() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setBoolean("P1",true);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetByte() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?, ?,?,?,?,?,?)");
    	try {
    	    cs.setByte("P1",(byte)1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetShort() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?, ?,?,?,?,?,?)");
    	try {
    	    cs.setShort("P1",(short)1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    
    public void testsetInt() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setInt("P1", 6);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetLong() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setLong("P1", (long)6000);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetFloat() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?, ?,?,?,?,?,?)");
    	try {
    	    cs.setFloat("P1",(float)6.123453);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetDouble() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?, ?,?,?,?,?,?)");
    	try {
    	    cs.setDouble("P5",(double)6.123453);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetDecimal() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?, ?,?,?,?,?,?)");
    	try {
    	    cs.setBigDecimal("P6",new BigDecimal("33.333"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetString() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setString("P4","test");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetBytes() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setBytes("P1",new byte[] { (byte)0xe0, 0x4f, (byte)0xd0,
    	    	    0x20, (byte)0xea, 0x3a, 0x69, 0x10, (byte)0xa2, (byte)0xd8, 0x08, 0x00, 0x2b,
    	    	    0x30, 0x30, (byte)0x9d });
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetDate() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.setDate("P1",Date.valueOf("2013-07-13"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetTime() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.setTime("P2",Time.valueOf("10:05:02"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetTimestamp() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.setTimestamp("P3",Timestamp.valueOf("2002-05-12 10:05:02.000000000"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetAsciiStream() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    	    cs.setAsciiStream("PAscii",is,1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetBinaryStream() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    	    cs.setBinaryStream("PBinary",is,1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetObject() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setObject("P1","Object",1,2);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetObject1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setObject("P1","Object",1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetObject2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setObject("P1","Object");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetCharacterStream() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    	    cs.setCharacterStream("P1",br,1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetDate1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.setDate("P1",Date.valueOf("2013-07-13"),Calendar.getInstance());
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetTime1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.setTime("P2",Time.valueOf("10:05:02"),Calendar.getInstance());
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetTimestamp1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.setTimestamp("P3",Timestamp.valueOf("2002-05-12 10:05:02.000000000"),Calendar.getInstance());
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNull1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setNull("P1",1,"Null");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetString() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getString("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetBoolean() throws SQLException
    {
    	CallableStatement cs =prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getBoolean("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetByte() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getByte("P1");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetShort() throws SQLException
    {
    	CallableStatement cs =prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getShort("P1");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetInt() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getInt("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetLong() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getLong("P3");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetFloat() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getFloat("P5");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetDouble() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getDouble("P5");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetBytes() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getBytes("P1");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetDate() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getDate("P1");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetTime() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getTime("P2");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetTimestamp() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getTimestamp("P3");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetObject() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getObject("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetBigDecimal() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?,?,?,?,?,?, ?,?)");
    	try {
    	    cs.getBigDecimal("P6");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
   
    public void testgetObject1() throws SQLException, MalformedURLException
    {
    	Map<String, Class<?>> format = new HashMap<String, Class<?>>();
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.getObject("P1",format);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetRef() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getRef("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetBlob() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getBlob("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetClob1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getClob("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetArray() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getArray("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetDate1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getDate("P1",Calendar.getInstance());
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetTime1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getTime("P2",Calendar.getInstance());
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetTimestamp1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?, ?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getTimestamp("P3",Calendar.getInstance());
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetURL() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC(?,?,?,?,?, ?, ?,?)");
    	try {
    	    cs.getURL("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testregisterOutParameter() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.registerOutParameter("String",1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testregisterOutParameter1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.registerOutParameter("String",1,2);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testregisterOutParameter2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.registerOutParameter("String",1);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testregisterOutParameter3() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.registerOutParameter("String1",1,"String2");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    //test  methods for jdbc 4.0
    
    public void testgetCharacterStream() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getCharacterStream("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    
    public void testgetNCharacterStream() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?, ?, ?,?,?, ?, ?,?)");
    	try {
    	    cs.getNCharacterStream("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    
    public void testgetNString() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?, ?, ?,?,?, ?, ?,?)");
    	try {
    	    cs.getNString("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetRowId() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?, ?, ?,?,?, ?, ?,?)");
    	try {
    	    cs.getRowId("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetRowId() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setRowId("P1",cs.getRowId("P2"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetBlob() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setBlob("P1",cs.getBlob("P2"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetClob() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setClob("P1",cs.getClob("P2"));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNString() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setNString("P1","value");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNCharacterStream1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    	    cs.setNCharacterStream("P1",br);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNCharacterStream2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    	    cs.setNCharacterStream("P1",br,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNClob() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		cs.setNClob("P1",cs.getNClob(1));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetClob1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    		cs.setNClob("P1",br);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetClob2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    		cs.setNClob("P1",br,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetClobInputStream1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		cs.setBlob("P1",is);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetClobInputStream2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		cs.setBlob("P1",is,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNClobInput1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    		cs.setNClob("P1",br);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetNClobInput2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    		cs.setNClob("P1",br,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    
    public void testgetNClob() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getNClob("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetSQLXML() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    	    cs.setSQLXML("P1",cs.getSQLXML(1));
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testgetSQLXML() throws SQLException
    {
    	CallableStatement cs = prepareCall("call NON_NUMERIC_TYPES_IN_AND_OUT_PROC (?,?,?,?,?,?,?,?)");
    	try {
    	    cs.getSQLXML("P4");
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetAsciiStream1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    	    cs.setAsciiStream("P1",is);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetAsciiStream2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    	    cs.setAsciiStream("P1",is,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetBinaryStream1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    	    cs.setBinaryStream("P1",is);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
   public void testsetBinaryStream2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?, ?, ?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    	    cs.setBinaryStream("P1",is,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetCharacterStream1() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?,?,?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    	    cs.setCharacterStream("P1",br);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    
    public void testsetCharacterStream2() throws SQLException
    {
    	CallableStatement cs = prepareCall("call TWO_IN_ONE_OUT_PROC (?,?,?)");
    	try {
    		String str = "This is a String";
    		InputStream is = new ByteArrayInputStream(str.getBytes());
    		BufferedReader br = new BufferedReader(new InputStreamReader(is));
    	    cs.setCharacterStream("P1",br,(long)345678788);
    	    fail("should have failed");
    	} catch (SQLFeatureNotSupportedException e) {
    	    assertSQLState("0A000", e);
    	}
    }
    


}