1 21 22 package org.apache.derbyTesting.functionTests.tests.jdbcapi; 23 24 import org.apache.derby.tools.ij; 25 import org.apache.derbyTesting.functionTests.util.TestUtil; 26 import org.apache.derbyTesting.functionTests.util.BigDecimalHandler; 27 28 29 import java.sql.*; 30 import java.math.*; 31 import java.io.*; 32 33 public class parameterMapping { 34 35 private static boolean HAVE_BIG_DECIMAL; 36 37 static{ 38 if(BigDecimalHandler.representation != BigDecimalHandler.BIGDECIMAL_REPRESENTATION) 39 HAVE_BIG_DECIMAL = false; 40 else 41 HAVE_BIG_DECIMAL = true; 42 } 43 44 private static int[] jdbcTypes = 45 { 46 Types.TINYINT, 47 Types.SMALLINT, 48 Types.INTEGER, 49 Types.BIGINT, 50 Types.REAL, 51 Types.FLOAT, 52 Types.DOUBLE, 53 Types.DECIMAL, 54 Types.NUMERIC, 55 Types.BIT, 56 Types.NULL, Types.CHAR, 58 Types.VARCHAR, 59 Types.LONGVARCHAR, 60 Types.NULL, Types.VARBINARY, 62 Types.NULL, Types.DATE, 64 Types.TIME, 65 Types.TIMESTAMP, 66 Types.CLOB, 67 Types.BLOB, 68 }; 69 70 71 private static String [] SQLTypes = 72 { 73 null, 74 "SMALLINT", 75 "INTEGER", 76 "BIGINT", 77 "REAL", 78 "FLOAT", 79 "DOUBLE", 80 "DECIMAL(10,5)", 81 null, 82 null, 83 null, 84 "CHAR(60)", 85 "VARCHAR(60)", 86 "LONG VARCHAR", 87 "CHAR(60) FOR BIT DATA", 88 "VARCHAR(60) FOR BIT DATA", 89 "LONG VARCHAR FOR BIT DATA", 90 "DATE", 91 "TIME", 92 "TIMESTAMP", 93 "CLOB(1k)", 94 "BLOB(1k)", 95 96 }; 97 98 private static Class [] B3_GET_OBJECT; 99 100 static{ 101 if(HAVE_BIG_DECIMAL){ 102 B3_GET_OBJECT = new Class [] { 103 java.lang.Integer .class, java.lang.Integer .class, java.lang.Integer .class, java.lang.Long .class, java.lang.Float .class, java.lang.Double .class, java.lang.Double .class, java.math.BigDecimal .class, java.math.BigDecimal .class, java.lang.Boolean .class, java.lang.Boolean .class, java.lang.String .class, java.lang.String .class, java.lang.String .class, byte[].class, byte[].class, byte[].class, java.sql.Date .class, java.sql.Time .class, java.sql.Timestamp .class, java.sql.Clob .class, java.sql.Blob .class, }; 126 } 127 else { 128 B3_GET_OBJECT = new Class [] { 129 java.lang.Integer .class, java.lang.Integer .class, java.lang.Integer .class, java.lang.Long .class, java.lang.Float .class, java.lang.Double .class, java.lang.Double .class, java.lang.String .class, java.lang.String .class, java.lang.Boolean .class, java.lang.Boolean .class, java.lang.String .class, java.lang.String .class, java.lang.String .class, byte[].class, byte[].class, byte[].class, java.sql.Date .class, java.sql.Time .class, java.sql.Timestamp .class, java.sql.Clob .class, java.sql.Blob .class, }; 152 } 153 } 154 155 156 157 158 159 private static final boolean _ = false; 160 private static final boolean X = true; 161 162 165 public static final boolean[][] B6 = { 166 167 179 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 180 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 181 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 182 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 183 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 184 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 185 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 186 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 187 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _}, 188 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, _}, 189 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, X, _, X, _, _}, 190 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, X, X, _, _}, 191 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, X, X, X, _, _}, 192 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, X, X, X, _, _, _, _, _}, 193 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, _}, 194 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, X, X, X, _, _, _, _, _}, 195 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, _}, 196 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X}, 197 198 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}, 199 }; 200 201 202 222 223 235 public static boolean[][] B2_MOD = { 236 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 237 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 238 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 239 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 240 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 241 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 242 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 243 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 244 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, X, X, X, _, _}, 245 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, _}, 246 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, X, _, X, _, _}, 247 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, X, X, _, _}, 248 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, X, X, X, _, _}, 249 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, _, _, X, _}, 250 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, X}, 251 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, _, _, X, _}, 252 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, _}, 253 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X}, 254 255 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}, 256 }; 257 258 259 260 public static boolean[][] B5 = { 272 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _}, 273 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 274 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 275 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 276 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 277 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 278 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 279 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, _}, 280 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, X, _, X, _, _}, 281 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, _, X, _, _, _}, 282 { _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _, X, X, X, _, _}, 283 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X}, 284 { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, _}, 285 286 288 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 289 { X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _, _, _, _, _, _}, 290 }; 291 292 293 private static boolean isDB2jNet; 294 295 public static void main(String [] args) throws Exception { 296 isDB2jNet = TestUtil.isNetFramework(); 297 System.out.println("Test parameterMapping starting"); 298 System.out.println("STILL TO RESOLVE -- Cloudscape getBoolean() allow conversion on strings to match JCC"); 299 System.out.println("STILL TO RESOLVE -- Cloudscape getXXX() disable on LOBs."); 300 try 301 { 302 ij.getPropertyArg(args); 305 Connection conn = ij.startJBMS(); 306 307 conn.setAutoCommit(false); 308 309 Statement scb = conn.createStatement(); 312 313 try { 314 scb.execute("DROP TABLE PM.LOB_GET"); 315 }catch (SQLException seq) { 316 } 317 scb.execute("CREATE TABLE PM.LOB_GET(ID INT, B BLOB, C CLOB)"); 318 PreparedStatement pscb = conn.prepareStatement("INSERT INTO PM.LOB_GET VALUES (?, ?, ?)"); 319 pscb.setInt(1, 0); 320 pscb.setNull(2, Types.BLOB); 321 pscb.setNull(3, Types.CLOB); 322 pscb.executeUpdate(); 323 324 pscb.setInt(1, 1); 325 { 326 byte[] data = new byte[6]; 327 data[0] = (byte) 0x32; 328 data[1] = (byte) 0x43; 329 data[2] = (byte) 0x72; 330 data[3] = (byte) 0x43; 331 data[4] = (byte) 0x00; 332 data[5] = (byte) 0x37; 333 334 pscb.setBinaryStream(2, new java.io.ByteArrayInputStream (data), 6); 335 } 336 pscb.setCharacterStream(3, new java.io.StringReader ("72"), 2); 337 pscb.executeUpdate(); 338 scb.close(); 339 pscb.close(); 340 conn.commit(); 341 342 343 344 for (int type = 0; type < SQLTypes.length; type++) { 345 346 String sqlType = SQLTypes[type]; 347 348 System.out.println("\n\ngetXXX on : " + (sqlType == null ? Integer.toString(jdbcTypes[type]) : sqlType)); 349 if (sqlType == null || jdbcTypes[type] == Types.NULL) { 350 System.out.println(" skipping"); 351 continue; 352 } 353 354 Statement s = conn.createStatement(); 355 356 try { 357 s.execute("DROP TABLE PM.TYPE_AS"); 358 }catch (SQLException seq) { 359 } 360 s.execute("CREATE TABLE PM.TYPE_AS(VAL " + SQLTypes[type] + ")"); 361 362 PreparedStatement psi = conn.prepareStatement("INSERT INTO PM.TYPE_AS(VAL) VALUES(?)"); 363 psi.setNull(1, jdbcTypes[type]); 364 psi.executeUpdate(); 365 366 367 PreparedStatement psq = conn.prepareStatement("SELECT VAL FROM PM.TYPE_AS"); 368 ResultSet rs = psq.executeQuery(); 369 ResultSetMetaData rsmd = rs.getMetaData(); 370 if (rsmd.getColumnType(1) != jdbcTypes[type]) { 371 System.out.println("FAIL - mismatch column type " + rsmd.getColumnType(1) + " expected " + jdbcTypes[type]); 372 } 373 rs.close(); 374 375 378 System.out.println(" NULL VALUE"); 379 getXXX(psq, type, true); 380 381 382 s.execute("DELETE FROM PM.TYPE_AS"); 383 384 if (setValidValue(psi, 1, jdbcTypes[type])) { 387 psi.executeUpdate(); 388 System.out.println(" VALID VALUE"); 389 getXXX(psq, type, false); 390 } 391 392 393 394 System.out.println("setNull() with all JDBC Types on " + SQLTypes[type]); 396 for (int st = 0; st <= jdbcTypes.length + 1; st++) { 397 398 if (st >= jdbcTypes.length || jdbcTypes[st] != Types.NULL) 399 { 400 int sqlTypeNull; 402 if (st == jdbcTypes.length + 1) 403 sqlTypeNull = 235350345; else if (st == jdbcTypes.length) 405 sqlTypeNull = Types.NULL; 406 else 407 sqlTypeNull = jdbcTypes[st]; 408 409 s.execute("DELETE FROM PM.TYPE_AS"); 410 411 SQLException sqleResult = null; 412 try { 413 System.out.print(" setNull(" + TestUtil.sqlNameFromJdbc(sqlTypeNull) + ") "); 414 psi.setNull(1, sqlTypeNull); 415 psi.executeUpdate(); 416 417 getValidValue(psq, jdbcTypes[type]); 419 System.out.println(""); 420 421 } catch (SQLException sqle) { 422 sqleResult = sqle; 423 if ("22005".equals(sqle.getSQLState())) 424 System.out.println("IC"); 425 else 426 dumpSQLExceptions(sqle); 427 428 } 429 430 436 s.execute("DELETE FROM PM.TYPE_AS"); 437 try { 438 System.out.print(" setNull with batching support(" + TestUtil.sqlNameFromJdbc(sqlTypeNull) + ") "); 439 psi.setNull(1, sqlTypeNull); 440 psi.addBatch(); 441 psi.executeBatch(); 442 443 getValidValue(psq, jdbcTypes[type]); 445 System.out.println(""); 446 447 } catch (SQLException sqle) { 448 sqleResult = sqle; 449 if ("22005".equals(sqle.getSQLState())) 450 System.out.println("IC"); 451 else 452 dumpSQLExceptions(sqle); 453 } 454 } 455 } 456 457 System.out.println("setXXX() with all JDBC Types on " + SQLTypes[type]); 458 System.out.println("For setXXX() methods that pass an object, a null and valid values are checked"); 459 setXXX(s, psi, psq, type); 460 461 psi.close(); 462 psq.close(); 463 s.execute("DROP TABLE PM.TYPE_AS"); 464 conn.commit(); 465 466 if (isDB2jNet) 467 continue; 468 469 try { 471 s.execute("DROP PROCEDURE PMP.TYPE_AS"); 472 }catch (SQLException seq) { 473 } 474 String procSQL; 475 if(HAVE_BIG_DECIMAL) { 476 procSQL = "CREATE PROCEDURE PMP.TYPE_AS(" + 477 "IN P1 " + SQLTypes[type] + 478 ", INOUT P2 " + SQLTypes[type] + 479 ", OUT P3 " + SQLTypes[type] + 480 ") LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL " + 481 " EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.ProcedureTest.pmap'"; 482 } else { 483 procSQL = "CREATE PROCEDURE PMP.TYPE_AS(" + 484 "IN P1 " + SQLTypes[type] + 485 ", INOUT P2 " + SQLTypes[type] + 486 ", OUT P3 " + SQLTypes[type] + 487 ") LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL " + 488 " EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.SimpleProcedureTest.pmap'"; 489 } 490 491 try { 492 if (!HAVE_BIG_DECIMAL && SQLTypes[type].equals("DECIMAL(10,5)")) 493 continue; 494 System.out.println(procSQL); 495 s.execute(procSQL); 496 } catch (SQLException sqle) { 497 System.out.println(sqle.getSQLState() + ":" + sqle.getMessage()); 498 continue; 499 } 500 501 for (int opt = 0; opt < jdbcTypes.length; opt++) { 503 int jopt = jdbcTypes[opt]; 504 if (jopt == Types.NULL) 505 continue; 506 507 CallableStatement csp = conn.prepareCall("CALL PMP.TYPE_AS(?, ?, ?)"); 508 509 boolean bothRegistered = true; 510 System.out.print("INOUT " + sqlType + " registerOutParameter(" + TestUtil.getNameFromJdbcType(jopt) + ") "); 511 try { 512 csp.registerOutParameter(2, jopt); 513 System.out.println("-- OK"); 514 } catch (SQLException sqle) { 515 System.out.println("-- " + sqle.getSQLState()); 516 bothRegistered = false; 517 } 518 System.out.print("OUT " + sqlType + " registerOutParameter(" + TestUtil.getNameFromJdbcType(jopt) + ") "); 519 try { 520 csp.registerOutParameter(3, jopt); 521 System.out.println("-- OK"); 522 } catch (SQLException sqle) { 523 System.out.println("-- " + sqle.getSQLState()); 524 bothRegistered = false; 525 } 526 527 if (bothRegistered) { 528 529 try { 530 531 if (setValidValue(csp, 1, jdbcTypes[type]) && setValidValue(csp, 2, jopt)) { 534 535 csp.execute(); 536 537 System.out.print("P2="); getOutValue(csp, 2, jopt); System.out.println(""); 539 System.out.print("P3="); getOutValue(csp, 3, jopt); System.out.println(""); 540 } 541 542 } catch (SQLException sqle) { 543 dumpSQLExceptions(sqle); 544 } 545 } 546 547 csp.close(); 548 549 } 550 551 552 s.execute("DROP PROCEDURE PMP.TYPE_AS"); 553 s.close(); 554 conn.commit(); 555 } 556 } 557 catch (SQLException sqle) { 558 unexpectedException(sqle); 559 } 560 catch (Throwable t) { 561 t.printStackTrace(System.out); 562 } 563 } 564 565 private static void getXXX(PreparedStatement ps, int type, boolean isNull) throws SQLException, java.io.IOException { 566 567 { 568 System.out.print(" getByte="); 569 ResultSet rs = ps.executeQuery(); 570 rs.next(); 571 boolean worked; 572 SQLException sqleResult = null;; 573 try { 574 System.out.print(rs.getByte(1)); 575 System.out.print(" was null " + rs.wasNull()); 576 worked = true; 577 578 } catch (SQLException sqle) { 579 sqleResult = sqle; 580 worked = false; 581 } 582 rs.close(); 583 judge_getXXX(worked, sqleResult, 0, type); 584 } 585 586 587 { 588 System.out.print(" getShort="); 589 ResultSet rs = ps.executeQuery(); 590 rs.next(); 591 boolean worked; 592 SQLException sqleResult = null;; 593 try { 594 System.out.print(rs.getShort(1)); 595 System.out.print(" was null " + rs.wasNull()); 596 worked = true; 597 598 } catch (SQLException sqle) { 599 sqleResult = sqle; 600 worked = false; 601 } 602 rs.close(); 603 judge_getXXX(worked, sqleResult, 1, type); 604 } 605 606 { 607 System.out.print(" getInt="); 608 ResultSet rs = ps.executeQuery(); 609 rs.next(); 610 boolean worked; 611 SQLException sqleResult = null;; 612 try { 613 System.out.print(rs.getInt(1)); 614 System.out.print(" was null " + rs.wasNull()); 615 worked = true; 616 617 } catch (SQLException sqle) { 618 sqleResult = sqle; 619 worked = false; 620 } 621 rs.close(); 622 judge_getXXX(worked, sqleResult, 2, type); 623 } 624 625 { 626 System.out.print(" getLong="); 627 ResultSet rs = ps.executeQuery(); 628 rs.next(); 629 boolean worked; 630 SQLException sqleResult = null;; 631 try { 632 System.out.print(rs.getLong(1)); 633 System.out.print(" was null " + rs.wasNull()); 634 worked = true; 635 636 } catch (SQLException sqle) { 637 sqleResult = sqle; 638 worked = false; 639 } 640 rs.close(); 641 judge_getXXX(worked, sqleResult, 3, type); 642 } 643 644 { 645 System.out.print(" getFloat="); 646 ResultSet rs = ps.executeQuery(); 647 rs.next(); 648 boolean worked; 649 SQLException sqleResult = null;; 650 try { 651 System.out.print(rs.getFloat(1)); 652 System.out.print(" was null " + rs.wasNull()); 653 worked = true; 654 655 } catch (SQLException sqle) { 656 sqleResult = sqle; 657 worked = false; 658 } 659 rs.close(); 660 judge_getXXX(worked, sqleResult, 4, type); 661 } 662 663 { 664 System.out.print(" getDouble="); 665 ResultSet rs = ps.executeQuery(); 666 rs.next(); 667 boolean worked; 668 SQLException sqleResult = null;; 669 try { 670 System.out.print(rs.getDouble(1)); 671 System.out.print(" was null " + rs.wasNull()); 672 worked = true; 673 674 } catch (SQLException sqle) { 675 sqleResult = sqle; 676 worked = false; 677 } 678 rs.close(); 679 judge_getXXX(worked, sqleResult, 5, type); 680 } 681 682 683 if(HAVE_BIG_DECIMAL) { 684 System.out.print(" getBigDecimal="); 685 ResultSet rs = ps.executeQuery(); 686 rs.next(); 687 boolean worked; 688 SQLException sqleResult = null;; 689 try { 690 System.out.print(rs.getBigDecimal(1)); 691 System.out.print(" was null " + rs.wasNull()); 692 worked = true; 693 694 } catch (SQLException sqle) { 695 sqleResult = sqle; 696 worked = false; 697 } 698 rs.close(); 699 judge_getXXX(worked, sqleResult, 6, type); 700 } 701 702 { 703 System.out.print(" getBoolean="); 704 ResultSet rs = ps.executeQuery(); 705 rs.next(); 706 boolean worked; 707 SQLException sqleResult = null;; 708 try { 709 System.out.print(rs.getBoolean(1)); 710 System.out.print(" was null " + rs.wasNull()); 711 worked = true; 712 713 } catch (SQLException sqle) { 714 sqleResult = sqle; 715 worked = false; 716 } 717 rs.close(); 718 judge_getXXX(worked, sqleResult, 7, type); 719 } 720 721 { 722 System.out.print(" getString="); 723 ResultSet rs = ps.executeQuery(); 724 rs.next(); 725 boolean worked; 726 SQLException sqleResult = null;; 727 try { 728 System.out.print(rs.getString(1)); 729 System.out.print(" was null " + rs.wasNull()); 730 worked = true; 731 732 } catch (SQLException sqle) { 733 sqleResult = sqle; 734 worked = false; 735 } 736 rs.close(); 737 judge_getXXX(worked, sqleResult, 8, type); 738 } 739 740 { 741 System.out.print(" getBytes="); 742 ResultSet rs = ps.executeQuery(); 743 rs.next(); 744 boolean worked; 745 SQLException sqleResult = null;; 746 try { 747 byte[] data = rs.getBytes(1) ; 748 System.out.print(data == null ? null : parameterMapping.showFirstTwo(data)); 749 System.out.print(" was null " + rs.wasNull()); 750 worked = true; 751 752 } catch (SQLException sqle) { 753 sqleResult = sqle; 754 worked = false; 755 } 756 rs.close(); 757 judge_getXXX(worked, sqleResult, 9, type); 758 } 759 760 { 761 System.out.print(" getDate="); 762 boolean worked; 763 SQLException sqleResult = null;; 764 ResultSet rs = null; 765 try { 766 rs = ps.executeQuery(); 767 rs.next(); 768 System.out.print(rs.getDate(1)); 769 System.out.print(" was null " + rs.wasNull()); 770 worked = true; 771 772 } catch (SQLException sqle) { 773 sqleResult = sqle; 774 worked = "22007".equals(sqle.getSQLState()); 776 if (worked) 777 System.out.print(sqle.getSQLState()); 778 } catch (Throwable t) { 779 System.out.print(t.toString()); 780 worked = false; 781 } 782 if (rs != null) 783 rs.close(); 784 judge_getXXX(worked, sqleResult, 10, type); 785 } 786 787 { 788 boolean worked; 789 SQLException sqleResult = null;; 790 ResultSet rs = null; 791 try { 792 System.out.print(" getTime="); 793 rs = ps.executeQuery(); 794 rs.next(); 795 System.out.print(rs.getTime(1)); 796 System.out.print(" was null " + rs.wasNull()); 797 worked = true; 798 799 } catch (SQLException sqle) { 800 sqleResult = sqle; 801 worked = "22007".equals(sqle.getSQLState()); 803 if (worked) 804 System.out.print(sqle.getSQLState()); 805 } catch (Throwable t) { 806 System.out.print(t.toString()); 807 worked = false; 808 } 809 if (rs != null) 810 rs.close(); 811 judge_getXXX(worked, sqleResult, 11, type); 812 } 813 814 { 815 boolean worked; 816 SQLException sqleResult = null;; 817 ResultSet rs = null; 818 try { 819 System.out.print(" getTimestamp="); 820 rs = ps.executeQuery(); 821 rs.next(); 822 System.out.print(rs.getTimestamp(1)); 823 System.out.print(" was null " + rs.wasNull()); 824 worked = true; 825 826 } catch (SQLException sqle) { 827 sqleResult = sqle; 828 worked = "22007".equals(sqle.getSQLState()); 830 if (worked) 831 System.out.print(sqle.getSQLState()); 832 } catch (Throwable t) { 833 System.out.print(t.toString()); 834 worked = false; 835 } 836 if (rs != null) 837 rs.close(); 838 judge_getXXX(worked, sqleResult, 12, type); 839 } 840 841 { 842 System.out.print(" getAsciiStream="); 843 ResultSet rs = ps.executeQuery(); 844 rs.next(); 845 boolean worked; 846 SQLException sqleResult = null;; 847 try { 848 InputStream is = rs.getAsciiStream(1); 849 if (!isNull || B6[13][type]) { 851 System.out.print(is == null ? "null" : parameterMapping.showFirstTwo(is)); 852 System.out.print(" was null " + rs.wasNull()); 853 } 854 worked = true; 855 856 } catch (SQLException sqle) { 857 sqleResult = sqle; 858 worked = false; 859 } 860 861 867 boolean judge = B6[13][type] || specificCheck(rs, worked, sqleResult, isNull); 868 rs.close(); 869 if (judge) 870 judge_getXXX(worked, sqleResult, 13, type); 871 } 872 873 { 874 System.out.print(" getBinaryStream="); 875 ResultSet rs = ps.executeQuery(); 876 rs.next(); 877 boolean worked; 878 SQLException sqleResult = null;; 879 try { 880 InputStream is = rs.getBinaryStream(1); 881 if (!isNull || B6[14][type]) { 882 System.out.print(is == null ? "null" : parameterMapping.showFirstTwo(is)); 883 System.out.print(" was null " + rs.wasNull()); 884 } 885 worked = true; 886 887 } catch (SQLException sqle) { 888 sqleResult = sqle; 889 worked = false; 890 } 891 boolean judge = B6[14][type] || specificCheck(rs, worked, sqleResult, isNull); 892 rs.close(); 893 if (judge) 894 judge_getXXX(worked, sqleResult, 14, type); 895 } 896 897 { 898 System.out.print(" getCharacterStream="); 899 ResultSet rs = ps.executeQuery(); 900 rs.next(); 901 boolean worked; 902 SQLException sqleResult = null;; 903 try { 904 Reader r = rs.getCharacterStream(1); 905 if (!isNull || B6[15][type]) { 906 System.out.print(r == null ? "null" : parameterMapping.showFirstTwo(r)); 907 System.out.print(" was null " + rs.wasNull()); 908 } 909 worked = true; 910 911 } catch (SQLException sqle) { 912 sqleResult = sqle; 913 worked = false; 914 } 915 boolean judge = B6[15][type] || specificCheck(rs, worked, sqleResult, isNull); 916 rs.close(); 917 if (judge) 918 judge_getXXX(worked, sqleResult, 15, type); 919 } 920 921 { 922 System.out.print(" getClob="); 923 ResultSet rs = ps.executeQuery(); 924 rs.next(); 925 boolean worked; 926 SQLException sqleResult = null;; 927 try { 928 Clob clob = rs.getClob(1); 929 if (!isNull || B6[16][type]) { 930 System.out.print(clob == null ? "null" : clob.getSubString(1, 10)); 931 System.out.print(" was null " + rs.wasNull()); 932 } 933 worked = true; 934 935 } catch (SQLException sqle) { 936 sqleResult = sqle; 937 worked = false; 938 } 939 boolean judge = B6[16][type] || specificCheck(rs, worked, sqleResult, isNull); 940 rs.close(); 941 if (judge) 942 judge_getXXX(worked, sqleResult, 16, type); 943 } 944 945 { 946 System.out.print(" getBlob="); 947 ResultSet rs = ps.executeQuery(); 948 rs.next(); 949 boolean worked; 950 SQLException sqleResult = null;; 951 try { 952 Blob blob = rs.getBlob(1); 953 if (!isNull || B6[17][type]) { 954 System.out.print(blob == null ? "null" : parameterMapping.showFirstTwo(blob.getBinaryStream())); 955 System.out.print(" was null " + rs.wasNull()); 956 } 957 worked = true; 958 959 } catch (SQLException sqle) { 960 sqleResult = sqle; 961 worked = false; 962 } 963 boolean judge = B6[17][type] || specificCheck(rs, worked, sqleResult, isNull); 964 rs.close(); 965 if (judge) 966 judge_getXXX(worked, sqleResult, 17, type); 967 } 968 969 { 970 System.out.print(" getUnicodeStream="); 971 ResultSet rs = ps.executeQuery(); 972 rs.next(); 973 boolean worked; 974 SQLException sqleResult = null;; 975 try { 976 InputStream is = rs.getUnicodeStream(1); 977 System.out.print(is == null ? "null" : "data"); 978 System.out.print(" was null " + rs.wasNull()); 979 worked = true; 980 } catch (NoSuchMethodError e){ 981 worked = true; 982 System.out.println("ResultSet.getUnicodeStream not present - correct for JSR169"); 983 } catch (SQLException sqle) { 984 sqleResult = sqle; 985 worked = false; 986 } 987 rs.close(); 988 if(TestUtil.HAVE_DRIVER_CLASS) 989 judge_getXXX(worked, sqleResult, 18, type); 990 } 991 992 { 994 System.out.print(" getObject="); 995 ResultSet rs = ps.executeQuery(); 996 rs.next(); 997 SQLException sqleResult = null;; 998 try { 999 1000 String msg; 1001 if(!SQLTypes[type].equals("DECIMAL(10,5)") || HAVE_BIG_DECIMAL) { 1002 Object o = rs.getObject(1); 1003 1004 Class cgo = B3_GET_OBJECT[type]; 1005 1006 String cname; 1007 if (cgo.equals(byte[].class)) 1008 cname = "byte[]"; 1009 else 1010 cname = cgo.getName(); 1011 1012 if (o == null) 1013 { 1014 msg = "null"; 1015 } 1016 else if (cgo.isInstance(o)) 1017 { 1018 msg = "CORRECT :" + cgo.getName(); 1019 } 1020 else 1021 { 1022 msg = "FAIL NOT :" + cgo.getName() + " is " + o.getClass().getName(); 1023 } 1024 } else { 1025 msg = "ResultSet.getObject not called for DECIMAL type for JSR169"; 1026 } 1027 1028 System.out.print(msg); 1029 System.out.println(" was null " + rs.wasNull()); 1030 1031 } catch (SQLException sqle) { 1032 sqleResult = sqle; 1033 } 1034 rs.close(); 1035 } 1036 1037 } 1038 1039 private static boolean specificCheck(ResultSet rs, boolean worked, SQLException sqleResult, boolean isNull) 1040 throws SQLException { 1041 boolean judge = true; 1042 if (worked && isNull && rs.wasNull()) 1043 { 1044 if (isDB2jNet) 1046 judge = false; 1047 } 1048 else if (!worked && isNull) 1049 { 1050 if (!isDB2jNet && "22005".equals(sqleResult.getSQLState())) 1051 judge = false; 1052 } 1053 if (!judge) 1054 System.out.println("SPECIFIC CHECK OK"); 1055 1056 return judge; 1057 } 1058 1059 private static void judge_getXXX(boolean worked, SQLException sqleResult, int whichCall, int type) { 1060 String msg; 1061 if (worked && B6[whichCall][type]) 1062 msg = " JDBC MATCH(OK)"; 1063 else if (worked) 1064 msg = " CLOUD EXT (OK)"; 1065 else if (B6[whichCall][type]) { 1066 if (sqleResult != null) 1067 showException(sqleResult); 1068 msg = " JDBC FAIL " + SQLTypes[type]; 1069 } 1070 else { 1071 1072 String sqlState = sqleResult.getSQLState(); 1073 if ("22005".equals(sqlState)) 1074 System.out.print("IC"); else if (sqlState == null) { 1076 if (sqleResult.getMessage().indexOf("Wrong result column type for requested conversion") != -1) 1078 System.out.print("IC"); 1079 else if (sqleResult != null) 1080 showException(sqleResult); 1081 } 1082 else if (sqleResult != null) 1083 showException(sqleResult); 1084 1085 msg = " JDBC MATCH (INVALID)"; 1086 } 1087 1088 System.out.println(msg); 1089 } 1090 private static void judge_setXXX(boolean worked, SQLException sqleResult, int whichCall, int type) { 1091 String msg; 1092 if (worked && B2_MOD[whichCall][type]) 1093 msg = " JDBC MATCH(OK)"; 1094 else if (worked) 1095 msg = " CLOUD EXT (OK)"; 1096 else if (B2_MOD[whichCall][type]) { 1097 if (sqleResult != null) 1098 showException(sqleResult); 1099 msg = " JDBC FAIL " + SQLTypes[type]; 1100 } 1101 else { 1102 msg = checkForInvalidConversion(sqleResult); 1103 if (msg == null) 1104 return; 1105 } 1106 1107 System.out.println(msg); 1108 } 1109 private static void judge_setObject(boolean worked, SQLException sqleResult, int b5o, int type) { 1110 String msg; 1111 if (worked && B5[b5o][type]) 1112 msg = " JDBC MATCH(OK)"; 1113 else if (worked) 1114 msg = " CLOUD EXT (OK)"; 1115 else if (B5[b5o][type]) { 1116 if (sqleResult != null) 1117 showException(sqleResult); 1118 msg = " JDBC FAIL " + SQLTypes[type]; 1119 } 1120 else { 1121 msg = checkForInvalidConversion(sqleResult); 1122 if (msg == null) 1123 return; 1124 } 1125 1126 System.out.println(msg); 1127 } 1128 1139 private static String checkForInvalidConversion(SQLException sqle) 1140 { 1141 if (sqle == null) 1142 return null; 1143 1144 boolean unknownException = true; 1145 SQLException e = sqle; 1146 while (e != null && unknownException == true) 1147 { 1148 if ("22005".equals(e.getSQLState()) || 1150 "XCL12".equals(e.getSQLState()) || 1151 e.getMessage().indexOf("Illegal Conv") != -1) 1152 { 1153 unknownException = false; 1154 System.out.print("IC"); 1155 break; 1156 } 1157 e = e.getNextException(); 1158 } 1159 if (unknownException) 1160 showException(sqle); 1161 1162 return " JDBC MATCH (INVALID)"; 1163 } 1164 private static void setXXX(Statement s, PreparedStatement psi, PreparedStatement psq, int type) throws SQLException, java.io.IOException { 1165 1166 1167 { 1168 s.execute("DELETE FROM PM.TYPE_AS"); 1169 1170 SQLException sqleResult = null; 1171 boolean worked; 1172 try { 1173 System.out.print(" setByte() "); 1174 psi.setByte(1, (byte) 98); 1175 psi.executeUpdate(); 1176 1177 getValidValue(psq, jdbcTypes[type]); 1178 1179 worked = true; 1180 1181 } catch (SQLException sqle) { 1182 sqleResult = sqle; 1183 worked = false; 1184 } 1185 judge_setXXX(worked, sqleResult, 0, type); 1186 } 1187 { 1189 s.execute("DELETE FROM PM.TYPE_AS"); 1190 1191 SQLException sqleResult = null; 1192 boolean worked; 1193 try { 1194 System.out.print(" setByte() as batch "); 1195 psi.setByte(1, (byte) 98); 1196 psi.addBatch(); 1197 psi.executeBatch(); 1198 1199 getValidValue(psq, jdbcTypes[type]); 1200 1201 worked = true; 1202 1203 } catch (SQLException sqle) { 1204 sqleResult = sqle; 1205 worked = false; 1206 } 1207 judge_setXXX(worked, sqleResult, 0, type); 1208 } 1209 { 1210 s.execute("DELETE FROM PM.TYPE_AS"); 1211 1212 SQLException sqleResult = null; 1213 boolean worked; 1214 try { 1215 System.out.print(" setShort() "); 1216 psi.setShort(1, (short) 98); 1217 psi.executeUpdate(); 1218 1219 getValidValue(psq, jdbcTypes[type]); 1220 1221 worked = true; 1222 1223 } catch (SQLException sqle) { 1224 sqleResult = sqle; 1225 worked = false; 1226 } 1227 judge_setXXX(worked, sqleResult, 1, type); 1228 } 1229 { 1231 s.execute("DELETE FROM PM.TYPE_AS"); 1232 1233 SQLException sqleResult = null; 1234 boolean worked; 1235 try { 1236 System.out.print(" setShort() as batch "); 1237 psi.setShort(1, (short) 98); 1238 psi.addBatch(); 1239 psi.executeBatch(); 1240 1241 getValidValue(psq, jdbcTypes[type]); 1242 1243 worked = true; 1244 1245 } catch (SQLException sqle) { 1246 sqleResult = sqle; 1247 worked = false; 1248 } 1249 judge_setXXX(worked, sqleResult, 1, type); 1250 } 1251 { 1252 s.execute("DELETE FROM PM.TYPE_AS"); 1253 1254 SQLException sqleResult = null; 1255 boolean worked; 1256 try { 1257 System.out.print(" setInt() "); 1258 psi.setInt(1, 98); 1259 psi.executeUpdate(); 1260 1261 getValidValue(psq, jdbcTypes[type]); 1262 1263 worked = true; 1264 1265 } catch (SQLException sqle) { 1266 sqleResult = sqle; 1267 worked = false; 1268 } 1269 judge_setXXX(worked, sqleResult, 2, type); 1270 } 1271 { 1273 s.execute("DELETE FROM PM.TYPE_AS"); 1274 1275 SQLException sqleResult = null; 1276 boolean worked; 1277 try { 1278 System.out.print(" setInt() as batch "); 1279 psi.setInt(1, 98); 1280 psi.addBatch(); 1281 psi.executeBatch(); 1282 1283 getValidValue(psq, jdbcTypes[type]); 1284 1285 worked = true; 1286 1287 } catch (SQLException sqle) { 1288 sqleResult = sqle; 1289 worked = false; 1290 } 1291 judge_setXXX(worked, sqleResult, 2, type); 1292 } 1293 { 1294 s.execute("DELETE FROM PM.TYPE_AS"); 1295 1296 SQLException sqleResult = null; 1297 boolean worked; 1298 try { 1299 System.out.print(" setLong() "); 1300 psi.setLong(1, 98L); 1301 psi.executeUpdate(); 1302 1303 getValidValue(psq, jdbcTypes[type]); 1304 1305 worked = true; 1306 1307 } catch (SQLException sqle) { 1308 sqleResult = sqle; 1309 worked = false; 1310 } 1311 judge_setXXX(worked, sqleResult, 3, type); 1312 } 1313 { 1315 s.execute("DELETE FROM PM.TYPE_AS"); 1316 1317 SQLException sqleResult = null; 1318 boolean worked; 1319 try { 1320 System.out.print(" setLong() as batch "); 1321 psi.setLong(1, 98L); 1322 psi.addBatch(); 1323 psi.executeBatch(); 1324 1325 getValidValue(psq, jdbcTypes[type]); 1326 1327 worked = true; 1328 1329 } catch (SQLException sqle) { 1330 sqleResult = sqle; 1331 worked = false; 1332 } 1333 judge_setXXX(worked, sqleResult, 3, type); 1334 } 1335 1336 { 1337 s.execute("DELETE FROM PM.TYPE_AS"); 1338 1339 SQLException sqleResult = null; 1340 boolean worked; 1341 try { 1342 System.out.print(" setFloat() "); 1343 psi.setFloat(1, 98.4f); 1344 psi.executeUpdate(); 1345 1346 getValidValue(psq, jdbcTypes[type]); 1347 1348 worked = true; 1349 1350 } catch (SQLException sqle) { 1351 sqleResult = sqle; 1352 worked = false; 1353 } 1354 judge_setXXX(worked, sqleResult, 4, type); 1355 } 1356 1357 { 1359 s.execute("DELETE FROM PM.TYPE_AS"); 1360 1361 SQLException sqleResult = null; 1362 boolean worked; 1363 try { 1364 System.out.print(" setFloat() as batch "); 1365 psi.setFloat(1, 98.4f); 1366 psi.addBatch(); 1367 psi.executeBatch(); 1368 1369 getValidValue(psq, jdbcTypes[type]); 1370 1371 worked = true; 1372 1373 } catch (SQLException sqle) { 1374 sqleResult = sqle; 1375 worked = false; 1376 } 1377 judge_setXXX(worked, sqleResult, 4, type); 1378 } 1379 1380 { 1381 s.execute("DELETE FROM PM.TYPE_AS"); 1382 1383 SQLException sqleResult = null; 1384 boolean worked; 1385 try { 1386 System.out.print(" setDouble() "); 1387 psi.setDouble(1, 98.5); 1388 psi.executeUpdate(); 1389 1390 getValidValue(psq, jdbcTypes[type]); 1391 1392 worked = true; 1393 1394 } catch (SQLException sqle) { 1395 sqleResult = sqle; 1396 worked = false; 1397 } 1398 judge_setXXX(worked, sqleResult, 5, type); 1399 } 1400 1401 { 1403 s.execute("DELETE FROM PM.TYPE_AS"); 1404 1405 SQLException sqleResult = null; 1406 boolean worked; 1407 try { 1408 System.out.print(" setDouble() as batch "); 1409 psi.setDouble(1, 98.5); 1410 psi.addBatch(); 1411 psi.executeBatch(); 1412 1413 getValidValue(psq, jdbcTypes[type]); 1414 1415 worked = true; 1416 1417 } catch (SQLException sqle) { 1418 sqleResult = sqle; 1419 worked = false; 1420 } 1421 judge_setXXX(worked, sqleResult, 5, type); 1422 } 1423 1424 1425 if(HAVE_BIG_DECIMAL){ 1426 { 1427 s.execute("DELETE FROM PM.TYPE_AS"); 1428 1429 SQLException sqleResult = null; 1430 boolean worked; 1431 try { 1432 System.out.print(" setBigDecimal() "); 1433 psi.setBigDecimal(1, new BigDecimal(99.0)); 1434 psi.executeUpdate(); 1435 1436 getValidValue(psq, jdbcTypes[type]); 1437 1438 worked = true; 1439 1440 } catch (SQLException sqle) { 1441 sqleResult = sqle; 1442 worked = false; 1443 } 1444 judge_setXXX(worked, sqleResult, 6, type); 1445 } 1446 { 1448 s.execute("DELETE FROM PM.TYPE_AS"); 1449 1450 SQLException sqleResult = null; 1451 boolean worked; 1452 try { 1453 System.out.print(" setBigDecimal() as batch "); 1454 psi.setBigDecimal(1, new BigDecimal(99.0)); 1455 psi.addBatch(); 1456 psi.executeBatch(); 1457 1458 getValidValue(psq, jdbcTypes[type]); 1459 1460 worked = true; 1461 1462 } catch (SQLException sqle) { 1463 sqleResult = sqle; 1464 worked = false; 1465 } 1466 judge_setXXX(worked, sqleResult, 6, type); 1467 } 1468 { 1470 s.execute("DELETE FROM PM.TYPE_AS"); 1471 1472 SQLException sqleResult = null; 1473 boolean worked; 1474 try { 1475 System.out.print(" setBigDecimal(null) "); 1476 psi.setBigDecimal(1, null); 1477 psi.executeUpdate(); 1478 1479 getValidValue(psq, jdbcTypes[type]); 1480 1481 worked = true; 1482 1483 } catch (SQLException sqle) { 1484 sqleResult = sqle; 1485 worked = false; 1486 } 1487 judge_setXXX(worked, sqleResult, 6, type); 1488 } 1489 1490 { 1492 s.execute("DELETE FROM PM.TYPE_AS"); 1493 1494 SQLException sqleResult = null; 1495 boolean worked; 1496 try { 1497 System.out.print(" setBigDecimal(null) as batch "); 1498 psi.setBigDecimal(1, null); 1499 psi.addBatch(); 1500 psi.executeBatch(); 1501 1502 getValidValue(psq, jdbcTypes[type]); 1503 1504 worked = true; 1505 1506 } catch (SQLException sqle) { 1507 sqleResult = sqle; 1508 worked = false; 1509 } 1510 judge_setXXX(worked, sqleResult, 6, type); 1511 } 1512 } 1513 1514 { 1515 s.execute("DELETE FROM PM.TYPE_AS"); 1516 1517 SQLException sqleResult = null; 1518 boolean worked; 1519 try { 1520 System.out.print(" setBoolean() "); 1521 psi.setBoolean(1, true); 1522 psi.executeUpdate(); 1523 1524 getValidValue(psq, jdbcTypes[type]); 1525 1526 worked = true; 1527 1528 } catch (SQLException sqle) { 1529 sqleResult = sqle; 1530 worked = false; 1531 } 1532 judge_setXXX(worked, sqleResult, 7, type); 1533 } 1534 { 1535 s.execute("DELETE FROM PM.TYPE_AS"); 1536 1537 SQLException sqleResult = null; 1538 boolean worked; 1539 try { 1540 System.out.print(" setBoolean() as batch "); 1541 psi.setBoolean(1, true); 1542 psi.addBatch(); 1543 psi.executeBatch(); 1544 1545 getValidValue(psq, jdbcTypes[type]); 1546 1547 worked = true; 1548 1549 } catch (SQLException sqle) { 1550 sqleResult = sqle; 1551 worked = false; 1552 } 1553 judge_setXXX(worked, sqleResult, 7, type); 1554 } 1555 { 1556 s.execute("DELETE FROM PM.TYPE_AS"); 1557 1558 SQLException sqleResult = null; 1559 boolean worked; 1560 try { 1561 System.out.print(" setString() "); 1562 psi.setString(1, "97"); 1563 psi.executeUpdate(); 1564 1565 getValidValue(psq, jdbcTypes[type]); 1566 1567 worked = true; 1568 1569 } catch (SQLException sqle) { 1570 sqleResult = sqle; 1571 worked = false; 1572 } catch (Throwable t) { 1573 System.out.println(t.getMessage()); 1575 worked = false; 1576 sqleResult = null; 1577 1578 } 1579 judge_setXXX(worked, sqleResult, 8, type); 1580 } 1581 { 1583 s.execute("DELETE FROM PM.TYPE_AS"); 1584 1585 SQLException sqleResult = null; 1586 boolean worked; 1587 try { 1588 System.out.print(" setString() as batch "); 1589 psi.setString(1, "97"); 1590 psi.addBatch(); 1591 psi.executeBatch(); 1592 1593 getValidValue(psq, jdbcTypes[type]); 1594 1595 worked = true; 1596 1597 } catch (SQLException sqle) { 1598 sqleResult = sqle; 1599 worked = false; 1600 } catch (Throwable t) { 1601 System.out.println(t.getMessage()); 1603 worked = false; 1604 sqleResult = null; 1605 1606 } 1607 judge_setXXX(worked, sqleResult, 8, type); 1608 } 1609 1610 { 1612 s.execute("DELETE FROM PM.TYPE_AS"); 1613 1614 SQLException sqleResult = null; 1615 boolean worked; 1616 try { 1617 System.out.print(" setString(null) "); 1618 psi.setString(1, null); 1619 psi.executeUpdate(); 1620 1621 getValidValue(psq, jdbcTypes[type]); 1622 1623 worked = true; 1624 1625 } catch (SQLException sqle) { 1626 sqleResult = sqle; 1627 worked = false; 1628 } catch (Throwable t) { 1629 System.out.println(t.getMessage()); 1631 worked = false; 1632 sqleResult = null; 1633 1634 } 1635 judge_setXXX(worked, sqleResult, 8, type); 1636 } 1637 { 1639 s.execute("DELETE FROM PM.TYPE_AS"); 1640 1641 SQLException sqleResult = null; 1642 boolean worked; 1643 try { 1644 System.out.print(" setString(null) as batch "); 1645 psi.setString(1, null); 1646 psi.addBatch(); 1647 psi.executeBatch(); 1648 1649 getValidValue(psq, jdbcTypes[type]); 1650 1651 worked = true; 1652 1653 } catch (SQLException sqle) { 1654 sqleResult = sqle; 1655 worked = false; 1656 } catch (Throwable t) { 1657 System.out.println(t.getMessage()); 1659 worked = false; 1660 sqleResult = null; 1661 1662 } 1663 judge_setXXX(worked, sqleResult, 8, type); 1664 } 1665 { 1666 s.execute("DELETE FROM PM.TYPE_AS"); 1667 1668 testSetStringInvalidValue(type,psi); 1670 } 1671 { 1672 s.execute("DELETE FROM PM.TYPE_AS"); 1673 1674 SQLException sqleResult = null; 1675 boolean worked; 1676 try { 1677 System.out.print(" setBytes() "); 1678 byte[] data = {(byte) 0x04, (byte) 0x03, (byte) 0xfd, (byte) 0xc3, (byte) 0x73}; 1679 psi.setBytes(1, data); 1680 psi.executeUpdate(); 1681 1682 getValidValue(psq, jdbcTypes[type]); 1683 1684 worked = true; 1685 1686 } catch (SQLException sqle) { 1687 sqleResult = sqle; 1688 worked = false; 1689 } 1690 judge_setXXX(worked, sqleResult, 9, type); 1691 } 1692 { 1693 s.execute("DELETE FROM PM.TYPE_AS"); 1694 1695 SQLException sqleResult = null; 1696 boolean worked; 1697 try { 1698 System.out.print(" setBytes() as batch"); 1699 byte[] data = {(byte) 0x04, (byte) 0x03, (byte) 0xfd, (byte) 0xc3, (byte) 0x73}; 1700 psi.setBytes(1, data); 1701 psi.addBatch(); 1702 psi.executeBatch(); 1703 1704 getValidValue(psq, jdbcTypes[type]); 1705 1706 worked = true; 1707 1708 } catch (SQLException sqle) { 1709 sqleResult = sqle; 1710 worked = false; 1711 } 1712 judge_setXXX(worked, sqleResult, 9, type); 1713 } 1714 { 1716 s.execute("DELETE FROM PM.TYPE_AS"); 1717 1718 SQLException sqleResult = null; 1719 boolean worked; 1720 try { 1721 System.out.print(" setBytes(null) "); 1722 psi.setBytes(1, null); 1723 psi.executeUpdate(); 1724 1725 getValidValue(psq, jdbcTypes[type]); 1726 1727 worked = true; 1728 1729 } catch (SQLException sqle) { 1730 sqleResult = sqle; 1731 worked = false; 1732 } 1733 judge_setXXX(worked, sqleResult, 9, type); 1734 } 1735 1736 { 1737 s.execute("DELETE FROM PM.TYPE_AS"); 1738 1739 SQLException sqleResult = null; 1740 boolean worked; 1741 try { 1742 System.out.print(" setBytes(null) as batch"); 1743 psi.setBytes(1, null); 1744 psi.addBatch(); 1745 psi.executeBatch(); 1746 1747 getValidValue(psq, jdbcTypes[type]); 1748 1749 worked = true; 1750 1751 } catch (SQLException sqle) { 1752 sqleResult = sqle; 1753 worked = false; 1754 } 1755 judge_setXXX(worked, sqleResult, 9, type); 1756 } 1757 { 1758 s.execute("DELETE FROM PM.TYPE_AS"); 1759 1760 SQLException sqleResult = null; 1761 boolean worked; 1762 try { 1763 System.out.print(" setDate() "); 1764 psi.setDate(1, java.sql.Date.valueOf("2004-02-14")); 1765 psi.executeUpdate(); 1766 1767 getValidValue(psq, jdbcTypes[type]); 1768 1769 worked = true; 1770 1771 } catch (SQLException sqle) { 1772 sqleResult = sqle; 1773 worked = false; 1774 } 1775 judge_setXXX(worked, sqleResult, 10, type); 1776 } 1777 { 1778 s.execute("DELETE FROM PM.TYPE_AS"); 1779 1780 SQLException sqleResult = null; 1781 boolean worked; 1782 try { 1783 System.out.print(" setDate() as batch "); 1784 psi.setDate(1, java.sql.Date.valueOf("2004-02-14")); 1785 psi.addBatch(); 1786 psi.executeBatch(); 1787 1788 getValidValue(psq, jdbcTypes[type]); 1789 1790 worked = true; 1791 1792 } catch (SQLException sqle) { 1793 sqleResult = sqle; 1794 worked = false; 1795 } 1796 judge_setXXX(worked, sqleResult, 10, type); 1797 } 1798 { 1800 s.execute("DELETE FROM PM.TYPE_AS"); 1801 1802 SQLException sqleResult = null; 1803 boolean worked; 1804 try { 1805 System.out.print(" setDate(null) "); 1806 psi.setDate(1, null); 1807 psi.executeUpdate(); 1808 1809 getValidValue(psq, jdbcTypes[type]); 1810 1811 worked = true; 1812 1813 } catch (SQLException sqle) { 1814 sqleResult = sqle; 1815 worked = false; 1816 } 1817 judge_setXXX(worked, sqleResult, 10, type); 1818 } 1819 1820 { 1822 s.execute("DELETE FROM PM.TYPE_AS"); 1823 1824 SQLException sqleResult = null; 1825 boolean worked; 1826 try { 1827 System.out.print(" setDate(null) as batch "); 1828 psi.setDate(1, null); 1829 psi.addBatch(); 1830 psi.executeBatch(); 1831 1832 getValidValue(psq, jdbcTypes[type]); 1833 1834 worked = true; 1835 1836 } catch (SQLException sqle) { 1837 sqleResult = sqle; 1838 worked = false; 1839 } 1840 judge_setXXX(worked, sqleResult, 10, type); 1841 } 1842 1843 { 1844 s.execute("DELETE FROM PM.TYPE_AS"); 1845 1846 SQLException sqleResult = null; 1847 boolean worked; 1848 try { 1849 System.out.print(" setTime() "); 1850 psi.setTime(1, java.sql.Time.valueOf("13:26:42")); 1851 psi.executeUpdate(); 1852 1853 getValidValue(psq, jdbcTypes[type]); 1854 1855 worked = true; 1856 1857 } catch (SQLException sqle) { 1858 sqleResult = sqle; 1859 worked = false; 1860 } 1861 judge_setXXX(worked, sqleResult, 11, type); 1862 } 1863 { 1864 s.execute("DELETE FROM PM.TYPE_AS"); 1865 1866 SQLException sqleResult = null; 1867 boolean worked; 1868 try { 1869 System.out.print(" setTime() as batch "); 1870 psi.setTime(1, java.sql.Time.valueOf("13:26:42")); 1871 psi.addBatch(); 1872 psi.executeBatch(); 1873 1874 getValidValue(psq, jdbcTypes[type]); 1875 1876 worked = true; 1877 1878 } catch (SQLException sqle) { 1879 sqleResult = sqle; 1880 worked = false; 1881 } 1882 judge_setXXX(worked, sqleResult, 11, type); 1883 } 1884 1885 { 1886 s.execute("DELETE FROM PM.TYPE_AS"); 1887 1888 SQLException sqleResult = null; 1889 boolean worked; 1890 try { 1891 System.out.print(" setTime(null) "); 1892 psi.setTime(1, null); 1893 psi.executeUpdate(); 1894 1895 getValidValue(psq, jdbcTypes[type]); 1896 1897 worked = true; 1898 1899 } catch (SQLException sqle) { 1900 sqleResult = sqle; 1901 worked = false; 1902 } 1903 judge_setXXX(worked, sqleResult, 11, type); 1904 } 1905 { 1906 s.execute("DELETE FROM PM.TYPE_AS"); 1907 1908 SQLException sqleResult = null; 1909 boolean worked; 1910 try { 1911 System.out.print(" setTime(null) as batch "); 1912 psi.setTime(1, null); 1913 psi.addBatch(); 1914 psi.executeBatch(); 1915 1916 getValidValue(psq, jdbcTypes[type]); 1917 1918 worked = true; 1919 1920 } catch (SQLException sqle) { 1921 sqleResult = sqle; 1922 worked = false; 1923 } 1924 judge_setXXX(worked, sqleResult, 11, type); 1925 } 1926 { 1927 s.execute("DELETE FROM PM.TYPE_AS"); 1928 1929 SQLException sqleResult = null; 1930 boolean worked; 1931 try { 1932 System.out.print(" setTimestamp() "); 1933 psi.setTimestamp(1, java.sql.Timestamp.valueOf("2004-02-23 17:14:24.097625551")); 1934 psi.executeUpdate(); 1935 1936 getValidValue(psq, jdbcTypes[type]); 1937 1938 worked = true; 1939 1940 } catch (SQLException sqle) { 1941 sqleResult = sqle; 1942 worked = false; 1943 } 1944 judge_setXXX(worked, sqleResult, 12, type); 1945 } 1946 { 1948 s.execute("DELETE FROM PM.TYPE_AS"); 1949 1950 SQLException sqleResult = null; 1951 boolean worked; 1952 try { 1953 System.out.print(" setTimestamp() as batch "); 1954 psi.setTimestamp(1, java.sql.Timestamp.valueOf("2004-02-23 17:14:24.097625551")); 1955 psi.addBatch(); 1956 psi.executeBatch(); 1957 1958 getValidValue(psq, jdbcTypes[type]); 1959 1960 worked = true; 1961 1962 } catch (SQLException sqle) { 1963 sqleResult = sqle; 1964 worked = false; 1965 } 1966 judge_setXXX(worked, sqleResult, 12, type); 1967 } 1968 1969 { 1970 s.execute("DELETE FROM PM.TYPE_AS"); 1971 1972 SQLException sqleResult = null; 1973 boolean worked; 1974 try { 1975 System.out.print(" setTimestamp(null) "); 1976 psi.setTimestamp(1, null); 1977 psi.executeUpdate(); 1978 1979 getValidValue(psq, jdbcTypes[type]); 1980 1981 worked = true; 1982 1983 } catch (SQLException sqle) { 1984 sqleResult = sqle; 1985 worked = false; 1986 } 1987 judge_setXXX(worked, sqleResult, 12, type); 1988 } 1989 { 1991 s.execute("DELETE FROM PM.TYPE_AS"); 1992 1993 SQLException sqleResult = null; 1994 boolean worked; 1995 try { 1996 System.out.print(" setTimestamp(null) as batch "); 1997 psi.setTimestamp(1, null); 1998 psi.addBatch(); 1999 psi.executeBatch(); 2000 2001 getValidValue(psq, jdbcTypes[type]); 2002 2003 worked = true; 2004 2005 } catch (SQLException sqle) { 2006 sqleResult = sqle; 2007 worked = false; 2008 } 2009 judge_setXXX(worked, sqleResult, 12, type); 2010 } 2011 2012 { 2013 s.execute("DELETE FROM PM.TYPE_AS"); 2014 2015 SQLException sqleResult = null; 2016 boolean worked; 2017 try { 2018 System.out.print(" setAsciiStream() "); 2019 byte[] data = new byte[6]; 2020 data[0] = (byte) 0x65; 2021 data[1] = (byte) 0x67; 2022 data[2] = (byte) 0x30; 2023 data[3] = (byte) 0x31; 2024 data[4] = (byte) 0x32; 2025 data[5] = (byte) 0x64; 2026 2027 psi.setAsciiStream(1, new java.io.ByteArrayInputStream (data), 6); 2028 psi.executeUpdate(); 2029 getValidValue(psq, jdbcTypes[type]); 2030 2031 worked = true; 2032 2033 } catch (SQLException sqle) { 2034 sqleResult = sqle; 2035 worked = false; 2036 } 2037 judge_setXXX(worked, sqleResult, 13, type); 2038 } 2039 { 2040 s.execute("DELETE FROM PM.TYPE_AS"); 2041 2042 SQLException sqleResult = null; 2043 boolean worked; 2044 try { 2045 System.out.print(" setAsciiStream() as batch "); 2046 byte[] data = new byte[6]; 2047 data[0] = (byte) 0x65; 2048 data[1] = (byte) 0x67; 2049 data[2] = (byte) 0x30; 2050 data[3] = (byte) 0x31; 2051 data[4] = (byte) 0x32; 2052 data[5] = (byte) 0x64; 2053 2054 psi.setAsciiStream(1, new java.io.ByteArrayInputStream (data), 6); 2055 psi.addBatch(); 2056 psi.executeBatch(); 2057 getValidValue(psq, jdbcTypes[type]); 2058 2059 worked = true; 2060 2061 } catch (SQLException sqle) { 2062 sqleResult = sqle; 2063 worked = false; 2064 } 2065 judge_setXXX(worked, sqleResult, 13, type); 2066 } 2067 2068 2069 { 2070 s.execute("DELETE FROM PM.TYPE_AS"); 2071 2072 SQLException sqleResult = null; 2073 boolean worked; 2074 try { 2075 System.out.print(" setAsciiStream(null) "); 2076 psi.setAsciiStream(1, null, 0); 2077 psi.executeUpdate(); 2078 getValidValue(psq, jdbcTypes[type]); 2079 2080 worked = true; 2081 2082 } catch (SQLException sqle) { 2083 sqleResult = sqle; 2084 worked = false; 2085 } 2086 judge_setXXX(worked, sqleResult, 13, type); 2087 } 2088 { 2089 s.execute("DELETE FROM PM.TYPE_AS"); 2090 2091 SQLException sqleResult = null; 2092 boolean worked; 2093 try { 2094 System.out.print(" setAsciiStream(null) as batch "); 2095 psi.setAsciiStream(1, null, 0); 2096 psi.addBatch(); 2097 psi.executeBatch(); 2098 getValidValue(psq, jdbcTypes[type]); 2099 2100 worked = true; 2101 2102 } catch (SQLException sqle) { 2103 sqleResult = sqle; 2104 worked = false; 2105 } 2106 judge_setXXX(worked, sqleResult, 13, type); 2107 } 2108 { 2109 s.execute("DELETE FROM PM.TYPE_AS"); 2110 2111 SQLException sqleResult = null; 2112 boolean worked; 2113 try { 2114 System.out.print(" setBinaryStream() "); 2115 byte[] data = new byte[6]; 2116 data[0] = (byte) 0x82; 2117 data[1] = (byte) 0x43; 2118 data[2] = (byte) 0xca; 2119 data[3] = (byte) 0xfe; 2120 data[4] = (byte) 0x00; 2121 data[5] = (byte) 0x32; 2122 2123 psi.setBinaryStream(1, new java.io.ByteArrayInputStream (data), 6); 2124 psi.executeUpdate(); 2125 getValidValue(psq, jdbcTypes[type]); 2126 2127 worked = true; 2128 2129 } catch (SQLException sqle) { 2130 sqleResult = sqle; 2131 worked = false; 2132 } 2133 judge_setXXX(worked, sqleResult, 14, type); 2134 } 2135 { 2136 s.execute("DELETE FROM PM.TYPE_AS"); 2137 2138 SQLException sqleResult = null; 2139 boolean worked; 2140 try { 2141 System.out.print(" setBinaryStream() as batch "); 2142 byte[] data = new byte[6]; 2143 data[0] = (byte) 0x82; 2144 data[1] = (byte) 0x43; 2145 data[2] = (byte) 0xca; 2146 data[3] = (byte) 0xfe; 2147 data[4] = (byte) 0x00; 2148 data[5] = (byte) 0x32; 2149 2150 psi.setBinaryStream(1, new java.io.ByteArrayInputStream (data), 6); 2151 psi.addBatch(); 2152 psi.executeBatch(); 2153 getValidValue(psq, jdbcTypes[type]); 2154 2155 worked = true; 2156 2157 } catch (SQLException sqle) { 2158 sqleResult = sqle; 2159 worked = false; 2160 } 2161 judge_setXXX(worked, sqleResult, 14, type); 2162 } 2163 2164 { 2165 s.execute("DELETE FROM PM.TYPE_AS"); 2166 2167 SQLException sqleResult = null; 2168 boolean worked; 2169 try { 2170 System.out.print(" setBinaryStream(null) "); 2171 psi.setBinaryStream(1, null, 0); 2172 psi.executeUpdate(); 2173 getValidValue(psq, jdbcTypes[type]); 2174 2175 worked = true; 2176 2177 } catch (SQLException sqle) { 2178 sqleResult = sqle; 2179 worked = false; 2180 } 2181 judge_setXXX(worked, sqleResult, 14, type); 2182 } 2183 { 2184 s.execute("DELETE FROM PM.TYPE_AS"); 2185 2186 SQLException sqleResult = null; 2187 boolean worked; 2188 try { 2189 System.out.print(" setBinaryStream(null) as batch "); 2190 psi.setBinaryStream(1, null, 0); 2191 psi.addBatch(); 2192 psi.executeBatch(); 2193 getValidValue(psq, jdbcTypes[type]); 2194 2195 worked = true; 2196 2197 } catch (SQLException sqle) { 2198 sqleResult = sqle; 2199 worked = false; 2200 } 2201 judge_setXXX(worked, sqleResult, 14, type); 2202 } 2203 2204 { 2205 s.execute("DELETE FROM PM.TYPE_AS"); 2206 2207 SQLException sqleResult = null; 2208 boolean worked; 2209 try { 2210 System.out.print(" setCharacterStream() "); 2211 psi.setCharacterStream(1, new java.io.StringReader ("89"), 2); 2212 psi.executeUpdate(); 2213 getValidValue(psq, jdbcTypes[type]); 2214 2215 worked = true; 2216 2217 } catch (SQLException sqle) { 2218 sqleResult = sqle; 2219 worked = false; 2220 } 2221 judge_setXXX(worked, sqleResult, 15, type); 2222 } 2223 { 2224 s.execute("DELETE FROM PM.TYPE_AS"); 2225 2226 SQLException sqleResult = null; 2227 boolean worked; 2228 try { 2229 System.out.print(" setCharacterStream() as batch "); 2230 psi.setCharacterStream(1, new java.io.StringReader ("89"), 2); 2231 psi.addBatch(); 2232 psi.executeBatch(); 2233 getValidValue(psq, jdbcTypes[type]); 2234 2235 worked = true; 2236 2237 } catch (SQLException sqle) { 2238 sqleResult = sqle; 2239 worked = false; 2240 } 2241 judge_setXXX(worked, sqleResult, 15, type); 2242 } 2243 2244 { 2245 s.execute("DELETE FROM PM.TYPE_AS"); 2246 2247 SQLException sqleResult = null; 2248 boolean worked; 2249 try { 2250 System.out.print(" setCharacterStream(null) "); 2251 psi.setCharacterStream(1, null, 0); 2252 psi.executeUpdate(); 2253 getValidValue(psq, jdbcTypes[type]); 2254 2255 worked = true; 2256 2257 } catch (SQLException sqle) { 2258 sqleResult = sqle; 2259 worked = false; 2260 } 2261 judge_setXXX(worked, sqleResult, 15, type); 2262 } 2263 { 2264 s.execute("DELETE FROM PM.TYPE_AS"); 2265 2266 SQLException sqleResult = null; 2267 boolean worked; 2268 try { 2269 System.out.print(" setCharacterStream(null) as batch "); 2270 psi.setCharacterStream(1, null, 0); 2271 psi.addBatch(); 2272 psi.executeBatch(); 2273 getValidValue(psq, jdbcTypes[type]); 2274 2275 worked = true; 2276 2277 } catch (SQLException sqle) { 2278 sqleResult = sqle; 2279 worked = false; 2280 } 2281 judge_setXXX(worked, sqleResult, 15, type); 2282 } 2283 2284 { 2285 s.execute("DELETE FROM PM.TYPE_AS"); 2286 2287 SQLException sqleResult = null; 2288 boolean worked; 2289 try { 2290 System.out.print(" setClob() "); 2291 2292 ResultSet rsc = s.executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1"); 2293 rsc.next(); 2294 Clob tester = rsc.getClob(1); 2295 rsc.close(); 2296 2297 2298 psi.setClob(1, tester); 2299 psi.executeUpdate(); 2300 getValidValue(psq, jdbcTypes[type]); 2301 2302 worked = true; 2303 2304 } catch (SQLException sqle) { 2305 sqleResult = sqle; 2306 worked = false; 2307 } 2308 judge_setXXX(worked, sqleResult, 16, type); 2309 } 2310 { 2311 s.execute("DELETE FROM PM.TYPE_AS"); 2312 2313 SQLException sqleResult = null; 2314 boolean worked; 2315 try { 2316 System.out.print(" setClob() as batch "); 2317 2318 ResultSet rsc = s.executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1"); 2319 rsc.next(); 2320 Clob tester = rsc.getClob(1); 2321 rsc.close(); 2322 2323 2324 psi.setClob(1, tester); 2325 psi.addBatch(); 2326 psi.executeBatch(); 2327 getValidValue(psq, jdbcTypes[type]); 2328 2329 worked = true; 2330 2331 } catch (SQLException sqle) { 2332 sqleResult = sqle; 2333 worked = false; 2334 } 2335 judge_setXXX(worked, sqleResult, 16, type); 2336 } 2337 2338 2339 { 2340 s.execute("DELETE FROM PM.TYPE_AS"); 2341 2342 SQLException sqleResult = null; 2343 boolean worked; 2344 try { 2345 System.out.print(" setClob(null) "); 2346 2347 psi.setClob(1, null); 2348 psi.executeUpdate(); 2349 getValidValue(psq, jdbcTypes[type]); 2350 2351 worked = true; 2352 2353 } catch (SQLException sqle) { 2354 sqleResult = sqle; 2355 worked = false; 2356 } 2357 judge_setXXX(worked, sqleResult, 16, type); 2358 } 2359 { 2360 s.execute("DELETE FROM PM.TYPE_AS"); 2361 2362 SQLException sqleResult = null; 2363 boolean worked; 2364 try { 2365 System.out.print(" setClob(null) as batch "); 2366 2367 psi.setClob(1, null); 2368 psi.addBatch(); 2369 psi.executeBatch(); 2370 getValidValue(psq, jdbcTypes[type]); 2371 2372 worked = true; 2373 2374 } catch (SQLException sqle) { 2375 sqleResult = sqle; 2376 worked = false; 2377 } 2378 judge_setXXX(worked, sqleResult, 16, type); 2379 } 2380 { 2381 s.execute("DELETE FROM PM.TYPE_AS"); 2382 SQLException sqleResult = null; 2383 boolean worked; 2384 try { 2385 System.out.print(" setBlob() "); 2386 2387 ResultSet rsc = s.executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1"); 2388 rsc.next(); 2389 Blob tester = rsc.getBlob(1); 2390 rsc.close(); 2391 2392 2393 psi.setBlob(1, tester); 2394 psi.executeUpdate(); 2395 getValidValue(psq, jdbcTypes[type]); 2396 2397 worked = true; 2398 2399 } catch (SQLException sqle) { 2400 sqleResult = sqle; 2401 worked = false; 2402 } 2403 judge_setXXX(worked, sqleResult, 17, type); 2404 } 2405 { 2406 s.execute("DELETE FROM PM.TYPE_AS"); 2407 SQLException sqleResult = null; 2408 boolean worked; 2409 try { 2410 System.out.print(" setBlob() as batch "); 2411 2412 ResultSet rsc = s.executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1"); 2413 rsc.next(); 2414 Blob tester = rsc.getBlob(1); 2415 rsc.close(); 2416 2417 2418 psi.setBlob(1, tester); 2419 psi.addBatch(); 2420 psi.executeBatch(); 2421 getValidValue(psq, jdbcTypes[type]); 2422 2423 worked = true; 2424 2425 } catch (SQLException sqle) { 2426 sqleResult = sqle; 2427 worked = false; 2428 } 2429 judge_setXXX(worked, sqleResult, 17, type); 2430 } 2431 { 2432 s.execute("DELETE FROM PM.TYPE_AS"); 2433 SQLException sqleResult = null; 2434 boolean worked; 2435 try { 2436 System.out.print(" setBlob(null) "); 2437 2438 psi.setBlob(1, null); 2439 psi.executeUpdate(); 2440 getValidValue(psq, jdbcTypes[type]); 2441 2442 worked = true; 2443 2444 } catch (SQLException sqle) { 2445 sqleResult = sqle; 2446 worked = false; 2447 } 2448 judge_setXXX(worked, sqleResult, 17, type); 2449 } 2450 { 2451 s.execute("DELETE FROM PM.TYPE_AS"); 2452 SQLException sqleResult = null; 2453 boolean worked; 2454 try { 2455 System.out.print(" setBlob(null) as batch "); 2456 2457 psi.setBlob(1, null); 2458 psi.addBatch(); 2459 psi.executeBatch(); 2460 getValidValue(psq, jdbcTypes[type]); 2461 2462 worked = true; 2463 2464 } catch (SQLException sqle) { 2465 sqleResult = sqle; 2466 worked = false; 2467 } 2468 judge_setXXX(worked, sqleResult, 17, type); 2469 } 2470 { 2471 s.execute("DELETE FROM PM.TYPE_AS"); 2472 2473 SQLException sqleResult = null; 2474 boolean worked; 2475 try { 2476 System.out.print(" setUnicodeStream() "); 2477 byte[] data = new byte[6]; 2478 data[0] = (byte) 0x82; 2479 data[1] = (byte) 0x43; 2480 data[2] = (byte) 0xca; 2481 data[3] = (byte) 0xfe; 2482 data[4] = (byte) 0x00; 2483 data[5] = (byte) 0x32; 2484 2485 try{ 2486 psi.setUnicodeStream(1, new java.io.ByteArrayInputStream (data), 6); 2487 } catch (NoSuchMethodError e){ 2488 System.out.println("ResultSet.setUnicodeStream not present - correct for JSR169"); 2489 } 2490 2491 if(TestUtil.HAVE_DRIVER_CLASS){ 2492 psi.executeUpdate(); 2493 getValidValue(psq, jdbcTypes[type]); 2494 } 2495 worked = true; 2496 2497 } catch (SQLException sqle) { 2498 sqleResult = sqle; 2499 worked = false; 2500 } 2501 if(TestUtil.HAVE_DRIVER_CLASS) 2502 judge_setXXX(worked, sqleResult, 14, type); 2503 } 2504 { 2505 s.execute("DELETE FROM PM.TYPE_AS"); 2506 2507 SQLException sqleResult = null; 2508 boolean worked; 2509 try { 2510 System.out.print(" setUnicodeStream(null) "); 2511 try{ 2512 psi.setUnicodeStream(1, null, 0); 2513 } catch (NoSuchMethodError e){ 2514 System.out.println("ResultSet.setUnicodeStream not present - correct for JSR169"); 2515 } 2516 2517 if(TestUtil.HAVE_DRIVER_CLASS){ 2518 psi.executeUpdate(); 2519 getValidValue(psq, jdbcTypes[type]); 2520 } 2521 worked = true; 2522 2523 } catch (SQLException sqle) { 2524 sqleResult = sqle; 2525 worked = false; 2526 } 2527 if(TestUtil.HAVE_DRIVER_CLASS) 2528 judge_setXXX(worked, sqleResult, 14, type); 2529 } 2530 2531 2532 { 2534 s.execute("DELETE FROM PM.TYPE_AS"); 2535 2536 SQLException sqleResult = null; 2537 boolean worked; 2538 try { 2539 System.out.print(" setObject(null) "); 2541 psi.setObject(1, null); 2542 psi.executeUpdate(); 2543 getValidValue(psq, jdbcTypes[type]); 2544 2545 worked = true; 2546 2547 } catch (SQLException sqle) { 2548 sqleResult = sqle; 2549 worked = false; 2550 } 2551 System.out.println(worked ? " FAIL " : (" OK " + sqleResult.getMessage())); 2552 } 2553 { 2554 s.execute("DELETE FROM PM.TYPE_AS"); 2555 2556 SQLException sqleResult = null; 2557 boolean worked; 2558 try { 2559 System.out.print(" setObject(null) as batch "); 2561 psi.setObject(1, null); 2562 psi.addBatch(); 2563 psi.executeBatch(); 2564 getValidValue(psq, jdbcTypes[type]); 2565 2566 worked = true; 2567 2568 } catch (SQLException sqle) { 2569 sqleResult = sqle; 2570 worked = false; 2571 } 2572 System.out.println(worked ? " FAIL " : (" OK " + sqleResult.getMessage())); 2573 } 2574 2575 setXXX_setObject(s, psi, psq, type, "46", "java.lang.String", 0); 2576 if(HAVE_BIG_DECIMAL) 2577 setXXX_setObject(s, psi, psq, type, BigDecimal.valueOf(72L), "java.math.BigDecimal", 1); 2578 setXXX_setObject(s, psi, psq, type, Boolean.TRUE, "java.lang.Boolean", 2); 2579 2580 setXXX_setObject(s, psi, psq, type, new Byte ((byte) 2), 2582 "java.lang.Byte", 13); 2583 setXXX_setObject(s, psi, psq, type, new Short ((short) 11), 2584 "java.lang.Short", 14); 2585 2586 setXXX_setObject(s, psi, psq, type, new Integer (74), "java.lang.Integer", 3); 2587 setXXX_setObject(s, psi, psq, type, new Long (79), "java.lang.Long", 4); 2588 setXXX_setObject(s, psi, psq, type, new Float (76.3f), "java.lang.Float", 5); 2589 setXXX_setObject(s, psi, psq, type, new Double (12.33d), "java.lang.Double", 6); 2590 2591 { 2592 byte[] data = {0x32, 0x39}; 2593 setXXX_setObject(s, psi, psq, type, data, "byte[]", 7); 2594 } 2595 2596 2597 setXXX_setObject(s, psi, psq, type, java.sql.Date.valueOf("2004-02-14"), "java.sql.Date", 8); 2598 setXXX_setObject(s, psi, psq, type, java.sql.Time.valueOf("13:26:42"), "java.sql.Time", 9); 2599 setXXX_setObject(s, psi, psq, type, java.sql.Timestamp.valueOf("2004-02-23 17:14:24.097625551"), "java.sql.Timestamp", 10); 2600 s.getConnection().commit(); 2601 2602 if (!isDB2jNet) { 2603 { 2604 ResultSet rsc = s.executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1"); 2605 rsc.next(); 2606 Blob tester = rsc.getBlob(1); 2607 rsc.close(); 2608 setXXX_setObject(s, psi, psq, type, tester, "java.sql.Blob", 11); 2609 } 2610 2611 { 2612 ResultSet rsc = s.executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1"); 2613 rsc.next(); 2614 Clob tester = rsc.getClob(1); 2615 rsc.close(); 2616 setXXX_setObject(s, psi, psq, type, tester, "java.sql.Clob", 12); 2617 } 2618 } 2619 } 2620 2621 private static void setXXX_setObject(Statement s, PreparedStatement psi, PreparedStatement psq, int type, Object value, String className, int b5o) 2622 throws SQLException, java.io.IOException 2623 { 2624 { 2625 s.execute("DELETE FROM PM.TYPE_AS"); 2626 2627 SQLException sqleResult = null; 2628 boolean worked; 2629 try { 2630 System.out.print(" setObject(" + className + ") "); 2631 psi.setObject(1, value); 2632 psi.executeUpdate(); 2633 getValidValue(psq, jdbcTypes[type]); 2634 2635 worked = true; 2636 2637 } catch (SQLException sqle) { 2638 sqleResult = sqle; 2639 worked = false; 2640 } catch (Throwable t) { 2641 System.out.println("FAIL " + t.getMessage()); 2642 return; 2643 } 2644 judge_setObject(worked, sqleResult, b5o, type); 2645 } 2646 { 2647 s.execute("DELETE FROM PM.TYPE_AS"); 2648 2649 SQLException sqleResult = null; 2650 boolean worked; 2651 try { 2652 System.out.print(" setObject(" + className + ") as batch "); 2653 psi.setObject(1, value); 2654 psi.addBatch(); 2655 psi.executeBatch(); 2656 getValidValue(psq, jdbcTypes[type]); 2657 2658 worked = true; 2659 2660 } catch (SQLException sqle) { 2661 sqleResult = sqle; 2662 worked = false; 2663 } catch (Throwable t) { 2664 System.out.println("FAIL " + t.getMessage()); 2665 return; 2666 } 2667 judge_setObject(worked, sqleResult, b5o, type); 2668 } 2669 } 2670 2671 private static void unexpectedException(SQLException sqle) { 2672 2673 System.out.print("FAIL unexpected exception - "); 2674 showException(sqle); 2675 sqle.printStackTrace(System.out); 2676 } 2677 2678 private static void showException(SQLException sqle) { 2679 do { 2680 String state = sqle.getSQLState(); 2681 if (state == null) 2682 state = "?????"; 2683 2684 String msg = sqle.getMessage(); 2685 if (msg == null) 2686 msg = "?? no message ??"; 2687 2688 System.out.print(" (" + state + "):" + msg); 2689 sqle = sqle.getNextException(); 2690 } while (sqle != null); 2691 } 2692 2693 private static boolean setValidValue(PreparedStatement ps, int param, int jdbcType) 2694 throws SQLException { 2695 2696 switch (jdbcType) { 2697 case Types.BIT: 2698 ps.setBoolean(param, true); 2699 return true; 2700 case Types.TINYINT: 2701 ps.setByte(param, (byte) 32); 2702 return true; 2703 case Types.SMALLINT: 2704 ps.setShort(param, (short) 32); 2705 return true; 2706 case Types.INTEGER: 2707 ps.setInt(param, 32); 2708 return true; 2709 case Types.BIGINT: 2710 ps.setLong(param, 32L); 2711 return true; 2712 case Types.REAL: 2713 ps.setFloat(param, 32.0f); 2714 return true; 2715 case Types.FLOAT: 2716 case Types.DOUBLE: 2717 ps.setDouble(param, 32.0); 2718 return true; 2719 case Types.DECIMAL: 2720 BigDecimalHandler.setBigDecimalString(ps, param, "32.0"); 2721 return true; 2722 case Types.CHAR: 2723 case Types.VARCHAR: 2724 case Types.LONGVARCHAR: 2725 ps.setString(param, "32"); 2726 return true; 2727 case Types.BINARY: 2728 case Types.VARBINARY: 2729 { 2730 byte[] data = {(byte) 0x04, (byte) 0x03, (byte) 0xfd, (byte) 0xc3, (byte) 0x73}; 2731 ps.setBytes(param, data); 2732 return true; 2733 } 2734 case Types.DATE: 2736 ps.setDate(param, java.sql.Date.valueOf("2004-02-14")); 2737 return true; 2738 case Types.TIME: 2739 ps.setTime(param, java.sql.Time.valueOf("13:26:42")); 2740 return true; 2741 case Types.TIMESTAMP: 2742 ps.setTimestamp(param, java.sql.Timestamp.valueOf("2004-02-23 17:14:24.097625551")); 2743 return true; 2744 case Types.CLOB: 2745 ps.setCharacterStream(param, new java.io.StringReader ("67"), 2); 2747 return true; 2748 case Types.BLOB: 2749 { 2751 byte[] data = new byte[6]; 2752 data[0] = (byte) 0x82; 2753 data[1] = (byte) 0x43; 2754 data[2] = (byte) 0xca; 2755 data[3] = (byte) 0xfe; 2756 data[4] = (byte) 0x00; 2757 data[5] = (byte) 0x32; 2758 2759 ps.setBinaryStream(param, new java.io.ByteArrayInputStream (data), 6); 2760 return true; 2761 } 2762 default: 2763 return false; 2764 } 2765 } 2766 2767 private static boolean getValidValue(PreparedStatement ps, int jdbcType) 2768 throws SQLException, IOException { 2769 2770 ResultSet rs = ps.executeQuery(); 2771 rs.next(); 2772 2773 switch (jdbcType) { 2774 case Types.SMALLINT: 2775 System.out.print("getShort=" + rs.getShort(1) + " was null " + rs.wasNull()); 2776 return true; 2777 case Types.INTEGER: 2778 System.out.print("getInt=" + rs.getInt(1) + " was null " + rs.wasNull()); 2779 return true; 2780 case Types.BIGINT: 2781 System.out.print("getLong=" + rs.getLong(1) + " was null " + rs.wasNull()); 2782 return true; 2783 case Types.REAL: 2784 System.out.print("getFloat=" + rs.getFloat(1) + " was null " + rs.wasNull()); 2785 return true; 2786 case Types.FLOAT: 2787 case Types.DOUBLE: 2788 System.out.print("getDouble=" + rs.getDouble(1) + " was null " + rs.wasNull()); 2789 return true; 2790 case Types.DECIMAL: 2791 System.out.print("getBigDecimal=" + BigDecimalHandler.getBigDecimalString(rs,1) + " was null " + rs.wasNull()); 2792 return true; 2793 case Types.CHAR: 2794 case Types.VARCHAR: 2795 case Types.LONGVARCHAR: 2796 { 2797 String s = rs.getString(1); 2798 if (s != null) 2799 { 2800 if (s.startsWith("com.ibm.db2.jcc.") || 2805 s.startsWith("org.apache.derby.client")) 2806 s = "<OBJECT.toString()>"; 2807 2808 2809 boolean hasNonAscii = false; 2810 for (int si = 0; si < s.length(); si++) 2812 { 2813 char c = s.charAt(si); 2814 if (c < (char) 0x20 || c >= (char) 0x7f) 2815 { 2816 hasNonAscii = true; 2817 break; 2818 } 2819 } 2820 2821 if (hasNonAscii) 2822 { 2823 StringBuffer sb = new StringBuffer (); 2824 2825 sb.append("EncodedString: >"); 2826 for (int si = 0; si < s.length(); si++) 2827 { 2828 sb.append(' '); 2829 sb.append((int) s.charAt(si)); 2830 } 2831 sb.append(" <"); 2832 s = sb.toString(); 2833 2834 } 2835 } 2836 System.out.print("getString=" + s + " was null " + rs.wasNull()); 2837 return true; 2838 } 2839 case Types.BINARY: 2840 case Types.VARBINARY: 2841 { 2842 byte[] data = rs.getBytes(1) ; 2843 System.out.print("getBytes=" + (data == null ? "null" : parameterMapping.showFirstTwo(data))); 2844 System.out.print(" was null " + rs.wasNull()); 2845 return true; 2846 } 2847 case Types.LONGVARBINARY: 2848 { 2849 InputStream is = rs.getBinaryStream(1); 2850 System.out.print("getBinaryStream=" + (is == null ? "null" : parameterMapping.showFirstTwo(is))); 2851 System.out.print(" was null " + rs.wasNull()); 2852 return true; 2853 } 2854 2855 case Types.DATE: 2856 System.out.print("getDate=" + rs.getDate(1) + " was null " + rs.wasNull()); 2857 return true; 2858 case Types.TIME: 2859 System.out.print("getTime=" + rs.getTime(1) + " was null " + rs.wasNull()); 2860 return true; 2861 case Types.TIMESTAMP: 2862 System.out.print("getTimestamp=" + rs.getTimestamp(1) + " was null " + rs.wasNull()); 2863 return true; 2864 case Types.CLOB: 2865 { 2866 Clob clob = rs.getClob(1); 2867 System.out.print("getClob=" + (clob == null ? "null" : parameterMapping.showFirstTwo(clob.getCharacterStream()))); 2868 System.out.print(" was null " + rs.wasNull()); 2869 return true; 2870 } 2871 case Types.BLOB: 2872 { 2873 Blob blob = rs.getBlob(1); 2874 System.out.print("getBlob=" + (blob == null ? "null" : parameterMapping.showFirstTwo(blob.getBinaryStream()))); 2875 System.out.print(" was null " + rs.wasNull()); 2876 return true; 2877 } 2878 default: 2879 System.out.println("FAIL JDBC TYPE IN getValidValue " + TestUtil.sqlNameFromJdbc(jdbcType)); 2880 return false; 2881 } 2882 } 2883 2884 private static boolean getOutValue(CallableStatement cs, int param, int jdbcType) 2885 throws SQLException, IOException { 2886 2887 switch (jdbcType) { 2888 case Types.BIT: 2889 System.out.print("cs.getBoolean=" + cs.getBoolean(param) + " was null " + cs.wasNull()); 2890 return true; 2891 case Types.TINYINT: 2892 System.out.print("cs.getByte=" + cs.getByte(param) + " was null " + cs.wasNull()); 2893 return true; 2894 2895 case Types.SMALLINT: 2896 System.out.print("cs.getShort=" + cs.getShort(param) + " was null " + cs.wasNull()); 2897 return true; 2898 case Types.INTEGER: 2899 System.out.print("cs.getInt=" + cs.getInt(param) + " was null " + cs.wasNull()); 2900 return true; 2901 case Types.BIGINT: 2902 System.out.print("cs.getLong=" + cs.getLong(param) + " was null " + cs.wasNull()); 2903 return true; 2904 case Types.REAL: 2905 System.out.print("cs.getFloat=" + cs.getFloat(param) + " was null " + cs.wasNull()); 2906 return true; 2907 case Types.FLOAT: 2908 case Types.DOUBLE: 2909 System.out.print("cs.getDouble=" + cs.getDouble(param) + " was null " + cs.wasNull()); 2910 return true; 2911 case Types.DECIMAL: 2912 System.out.print("cs.getBigDecimal=" + BigDecimalHandler.getBigDecimalString(cs,param,jdbcType) + " was null " + cs.wasNull()); 2913 return true; 2914 case Types.CHAR: 2915 case Types.VARCHAR: 2916 case Types.LONGVARCHAR: 2917 System.out.print("cs.getString=" + cs.getString(param) + " was null " + cs.wasNull()); 2918 return true; 2919 case Types.BINARY: 2920 case Types.VARBINARY: 2921 case Types.LONGVARBINARY: 2922 { 2923 byte[] data = cs.getBytes(param) ; 2924 System.out.print("cs.getBytes=" + (data == null ? "null" : parameterMapping.showFirstTwo(data))); 2925 System.out.print(" was null " + cs.wasNull()); 2926 return true; 2927 } 2928 2929 case Types.DATE: 2930 System.out.print("cs.getDate=" + cs.getDate(param) + " was null " + cs.wasNull()); 2931 return true; 2932 case Types.TIME: 2933 System.out.print("cs.getTime=" + cs.getTime(param) + " was null " + cs.wasNull()); 2934 return true; 2935 case Types.TIMESTAMP: 2936 System.out.print("cs.getTimestamp=" + cs.getTime(param) + " was null " + cs.wasNull()); 2937 return true; 2938 case Types.CLOB: 2939 { 2940 Clob clob = cs.getClob(param); 2941 System.out.print("cs.getClob=" + (clob == null ? "null" : parameterMapping.showFirstTwo(clob.getCharacterStream()))); 2942 System.out.print(" was null " + cs.wasNull()); 2943 return true; 2944 } 2945 case Types.BLOB: 2946 { 2947 Blob blob = cs.getBlob(param); 2948 System.out.print("cs.getBlob=" + (blob == null ? "null" : parameterMapping.showFirstTwo(blob.getBinaryStream()))); 2949 System.out.print(" was null " + cs.wasNull()); 2950 return true; 2951 } 2952 default: 2953 System.out.println("FAIL JDBC TYPE IN getOutValue " + TestUtil.sqlNameFromJdbc(jdbcType)); 2954 return false; 2955 } 2956 } 2957 2958 static void dumpSQLExceptions (SQLException se) { 2959 2960 while (se != null) { 2961 System.out.println("SQLSTATE("+se.getSQLState()+"): " + se.toString()); 2962 se = se.getNextException(); 2963 } 2964 } 2965 2966 2975 private static void testSetStringInvalidValue(int type, PreparedStatement psi) { 2976 switch (jdbcTypes[type]) 2979 { 2980 case Types.CHAR: 2981 case Types.VARCHAR: 2982 case Types.LONGVARCHAR: 2983 case Types.CLOB: 2984 return; 2985 } 2986 2987 String sqlType = SQLTypes[type]; 2988 try { 2989 System.out.print(" setString(\"Invalid Value\") " ); 2990 psi.setString(1,"Invalid Value"); 2991 psi.executeUpdate(); 2992 String error = "FAIL - setString(1,\"Invalld Value\") for type " + 2994 sqlType + " did not throw an exception as expected"; 2995 } 2996 catch (SQLException sqle) 2997 { 2998 2999 if ("22018".equals(sqle.getSQLState())|| 3000 "XCL12".equals(sqle.getSQLState())|| 3001 "22007".equals(sqle.getSQLState())|| 3002 (sqle.getMessage().indexOf("Invalid data conversion") != -1) || 3003 (sqle.getMessage().indexOf("Illegal Conversion") != -1)) 3004 System.out.println(" IC (Expected)"); 3005 else 3006 dumpSQLExceptions(sqle); 3007 } 3008 catch (Exception e) 3009 { 3010 if (TestUtil.isJCCFramework() && 3013 e instanceof IllegalArgumentException ) 3014 System.out.println( e.getMessage()); 3015 else 3016 System.out.println("FAIL: Unexpected Exception " + e.getMessage()); 3017 } 3018 } 3019 3020 private static String showFirstTwo(java.io.Reader in) throws java.io.IOException { 3021 3022 int b1 = in.read(); 3023 int b2 = in.read(); 3024 in.close(); 3025 3026 return "0x" + Integer.toHexString(b1) + "," + "0x" + Integer.toHexString(b2); 3027 } 3028 private static String showFirstTwo(java.io.InputStream in) throws java.io.IOException { 3029 3030 int b1 = in.read(); 3031 int b2 = in.read(); 3032 in.close(); 3033 3034 return "0x" + Integer.toHexString(b1) + "," + "0x" + Integer.toHexString(b2); 3035 } 3036 private static String showFirstTwo(byte[] data) { 3037 3038 int b1 = data[0]; 3039 int b2 = data[1]; 3040 3041 return "0x" + Integer.toHexString(((int) b1) & 0xff) + "," + "0x" + Integer.toHexString(((int) b2) & 0xff); 3042 } 3043} 3044 | Popular Tags |