db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r509361 [2/3] - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
Date Mon, 19 Feb 2007 22:43:41 GMT

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java?view=auto&rev=509361
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java Mon Feb 19 14:43:40 2007
@@ -0,0 +1,3049 @@
+/**
+ * 
+ */
+package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+
+import org.apache.derby.tools.ij;
+import org.apache.derbyTesting.functionTests.util.BigDecimalHandler;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+
+/**
+ * @author kmarsden
+ * 
+ */
+public class ParameterMappingTest extends BaseJDBCTestCase {
+    private static boolean HAVE_BIG_DECIMAL;
+
+    static {
+        if (BigDecimalHandler.representation != BigDecimalHandler.BIGDECIMAL_REPRESENTATION)
+            HAVE_BIG_DECIMAL = false;
+        else
+            HAVE_BIG_DECIMAL = true;
+    }
+
+    private static int[] jdbcTypes = { Types.TINYINT, Types.SMALLINT,
+            Types.INTEGER, Types.BIGINT, Types.REAL, Types.FLOAT, Types.DOUBLE,
+            Types.DECIMAL, Types.NUMERIC, Types.BIT, Types.NULL, // Types.BOOLEAN
+            Types.CHAR, Types.VARCHAR, Types.LONGVARCHAR, Types.NULL, // Types.BINARY,
+            Types.VARBINARY, Types.NULL, // Types.LONGVARBINARY,
+            Types.DATE, Types.TIME, Types.TIMESTAMP, Types.CLOB, Types.BLOB, };
+
+    private static String[] SQLTypes = { null, "SMALLINT", "INTEGER", "BIGINT",
+            "REAL", "FLOAT", "DOUBLE", "DECIMAL(10,5)", null, null, null,
+            "CHAR(60)", "VARCHAR(60)", "LONG VARCHAR", "CHAR(60) FOR BIT DATA",
+            "VARCHAR(60) FOR BIT DATA", "LONG VARCHAR FOR BIT DATA", "DATE",
+            "TIME", "TIMESTAMP", "CLOB(1k)", "BLOB(1k)",
+
+    };
+
+    private static Class[] B3_GET_OBJECT;
+
+    static {
+        if (HAVE_BIG_DECIMAL) {
+            B3_GET_OBJECT = new Class[] { java.lang.Integer.class, // Types.TINYINT,
+                    java.lang.Integer.class, // Types.SMALLINT,
+                    java.lang.Integer.class, // Types.INTEGER,
+                    java.lang.Long.class, // Types.BIGINT,
+                    java.lang.Float.class, // Types.REAL,
+                    java.lang.Double.class, // Types.FLOAT,
+                    java.lang.Double.class, // Types.DOUBLE,
+                    java.math.BigDecimal.class, // Types.DECIMAL,
+                    java.math.BigDecimal.class, // Types.NUMERIC,
+                    java.lang.Boolean.class, // Types.BIT,
+                    java.lang.Boolean.class, // Types.BOOLEAN
+                    java.lang.String.class, // Types.CHAR,
+                    java.lang.String.class, // Types.VARCHAR,
+                    java.lang.String.class, // Types.LONGVARCHAR,
+                    byte[].class, // Types.NULL, //Types.BINARY,
+                    byte[].class, // Types.VARBINARY,
+                    byte[].class, // Types.LONGVARBINARY,
+                    java.sql.Date.class, // Types.DATE,
+                    java.sql.Time.class, // Types.TIME,
+                    java.sql.Timestamp.class, // Types.TIMESTAMP,
+                    java.sql.Clob.class, // Types.CLOB,
+                    java.sql.Blob.class, // Types.BLOB,
+            };
+        } else {
+            B3_GET_OBJECT = new Class[] { java.lang.Integer.class, // Types.TINYINT,
+                    java.lang.Integer.class, // Types.SMALLINT,
+                    java.lang.Integer.class, // Types.INTEGER,
+                    java.lang.Long.class, // Types.BIGINT,
+                    java.lang.Float.class, // Types.REAL,
+                    java.lang.Double.class, // Types.FLOAT,
+                    java.lang.Double.class, // Types.DOUBLE,
+                    java.lang.String.class, // Types.DECIMAL,
+                    java.lang.String.class, // Types.NUMERIC,
+                    java.lang.Boolean.class, // Types.BIT,
+                    java.lang.Boolean.class, // Types.BOOLEAN
+                    java.lang.String.class, // Types.CHAR,
+                    java.lang.String.class, // Types.VARCHAR,
+                    java.lang.String.class, // Types.LONGVARCHAR,
+                    byte[].class, // Types.NULL, //Types.BINARY,
+                    byte[].class, // Types.VARBINARY,
+                    byte[].class, // Types.LONGVARBINARY,
+                    java.sql.Date.class, // Types.DATE,
+                    java.sql.Time.class, // Types.TIME,
+                    java.sql.Timestamp.class, // Types.TIMESTAMP,
+                    java.sql.Clob.class, // Types.CLOB,
+                    java.sql.Blob.class, // Types.BLOB,
+            };
+        }
+    }
+
+    private static final boolean _ = false;
+
+    private static final boolean X = true;
+
+    /**
+     * JDBC 3.0 spec Table B6 - Use of ResultSet getter Methods to Retrieve JDBC
+     * Data Types
+     */
+    public static final boolean[][] B6 = {
+
+     // Types. T S I B R F D D N B B C V L B V L D T T C B
+            // I M N I E L O E U I O H A O I A O A I I L L
+            // N A T G A O U C M T O A R N N R N T M M O O
+            // Y L E I L A B I E   L R C G A B G E E E B B
+            // I L G N   T L M R   E   H V R I V     S
+            // N I E T     E A I   A   A A Y N A     T
+            // T N R         L C   N   R R   A R     A
+            //   T                       C   R B     M
+            //                           H   B I     P
+            //                           A   I N
+            //                           R   N
+
+            /* 0 getByte */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 1 getShort */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 2 getInt */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 3 getLong */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 4 getFloat */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 5 getDouble */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 6 getBigDecimal */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _,
+                    _, _, _, _, _, _, _ },
+            /* 7 getBoolean */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 8 getString */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,
+                    X, X, X, X, _, _ },
+            /* 9 getBytes */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X,
+                    X, _, _, _, _, _ },
+            /* 10 getDate */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _,
+                    X, _, X, _, _ },
+            /* 11 getTime */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _,
+                    _, X, X, _, _ },
+            /* 12 getTimestamp */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _,
+                    _, _, X, X, X, _, _ },
+            /* 13 getAsciiStream */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X,
+                    X, X, X, _, _, _, _, _ },
+            /* 14 getBinaryStream */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    X, X, X, _, _, _, _, _ },
+            /* 15 getCharStream */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, X,
+                    X, X, _, _, _, _, _ },
+            /* 16 getClob */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, X, _ },
+            /* 17 getBlob */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, _, X },
+
+            /* 18 getUnicodeStream */{ _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, _, _, _, _, _ }, };
+
+    /**
+     * JDBC 3.0 Section 13.2.2.1 specifies that table B-2 is used to specify
+     * type mappings from the Java types (e.g. int as setInt) to the JDBC SQL
+     * Type (Types.INT).
+     * 
+     * This table does not include stream methods and does not include
+     * conversions specified elsewhere in the text, Namely
+     * 
+     * Section 16.3.2 setBinaryStream may be used to set a BLOB setAsciiStream
+     * and setCharacterStream may be used to set a CLOB
+     * 
+     * Thus this B2_MOD table is laid out like the B6 table and makes the
+     * assumptions that
+     *  - Any Java numeric type can be used to set any SQL numeric type - Any
+     * Java numeric type can be used to set any SQL CHAR type - Numeric and
+     * date/time java types can be converted to SQL Char values.
+     * 
+     * 
+     */
+
+    // Types. T S I B R F D D N B B C V L B V L D T T C B
+    //        I M N I E L O E U I O H A O I A O A I I L L
+    //        N A T G A O U C M T O A R N N R N T M M O O
+    //        Y L E I L A B I E   L R C G A B G E E E B B
+    //        I L G N   T L M R   E   H V R I V S
+    //        N I E T     E A I   A   A A Y N A T
+    //        T N R         L C   N   R R   A R A
+    //          T                       C   R B M
+    //                                  H   B I P
+    //                                  A   I N
+    //                                  R   N
+    public static boolean[][] B2_MOD = {
+            /* 0 setByte */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 1 setShort */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 2 setInt */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 3 setLong */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 4 setFloat */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 5 setDouble */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 6 setBigDecimal */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _,
+                    _, _, _, _, _, _, _ },
+            /* 7 setBoolean */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 8 setString */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, X, X, X, _, _ },
+            /* 9 setBytes */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X,
+                    X, _, _, _, _, _ },
+            /* 10 setDate */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _,
+                    X, _, X, _, _ },
+            /* 11 setTime */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _,
+                    _, X, X, _, _ },
+            /* 12 setTimestamp */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _,
+                    _, _, X, X, X, _, _ },
+            /* 13 setAsciiStream */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X,
+                    _, _, _, _, _, _, X, _ },
+            /* 14 setBinaryStream */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    X, X, X, _, _, _, _, X },
+            /* 15 setCharStream */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _,
+                    _, _, _, _, _, X, _ },
+            /* 16 setClob */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, X, _ },
+            /* 17 setBlob */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, _, X },
+
+            /* 18 setUnicodeStream */{ _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, _, _, _, _, _ }, };
+
+    /** Table B5 conversion of Objects using setObject */
+   //  Types. T S I B R F D D N B B C V L B V L D T T C B
+    //        I M N I E L O E U I O H A O I A O A I I L L
+    //        N A T G A O U C M T O A R N N R N T M M O O
+    //        Y L E I L A B I E   L R C G A B G E E E B B
+    //        I L G N   T L M R   E   H V R I V S
+    //        N I E T     E A I   A   A A Y N A T
+    //        T N R         L C   N   R R   A R A
+    //          T                       C   R B M
+    //                                  H   B I P
+    //                                  A   I N
+    //                                  R   N
+    public static boolean[][] B5 = {
+            /* 0 String */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,
+                    X, X, X, _, _ },
+            /* 1 BigDecimal */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _,
+                    _, _, _, _, _, _, _ },
+            /* 2 Boolean */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 3 Integer */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _,
+                    _, _, _, _, _, _ },
+            /* 4 Long */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 5 Float */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 6 Double */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 7 byte[] */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, X, X, X,
+                    _, _, _, _, _ },
+            /* 8 Date */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _,
+                    X, _, X, _, _ },
+            /* 9 Time */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _, _,
+                    _, X, _, _, _ },
+            /* 10 Timestamp */{ _, _, _, _, _, _, _, _, _, _, _, X, X, X, _, _,
+                    _, X, X, X, _, _ },
+            /* 11 Blob */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, _, X },
+            /* 12 Clob */{ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+                    _, _, _, X, _ },
+
+            // Byte and Short were added to this table in JDBC 4.0. (See
+            // DERBY-1500.)
+
+            /* 13 Byte */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ },
+            /* 14 Short */{ X, X, X, X, X, X, X, X, X, X, X, X, X, X, _, _, _,
+                    _, _, _, _, _ }, };
+
+    /**
+     * @param arg0
+     */
+    public ParameterMappingTest(String arg0) {
+        super(arg0);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        Connection conn = getConnection();
+
+        conn.setAutoCommit(false);
+
+        // create simple a table with BLOB and CLOB thta
+        // can be used to for setBlob/setClob testing.
+        Statement scb = conn.createStatement();
+
+        scb.execute("CREATE TABLE PM.LOB_GET(ID INT, B BLOB, C CLOB)");
+        PreparedStatement pscb = conn
+                .prepareStatement("INSERT INTO PM.LOB_GET VALUES (?, ?, ?)");
+        pscb.setInt(1, 0);
+        pscb.setNull(2, Types.BLOB);
+        pscb.setNull(3, Types.CLOB);
+        pscb.executeUpdate();
+
+        pscb.setInt(1, 1);
+        {
+            byte[] data = new byte[6];
+            data[0] = (byte) 0x32;
+            data[1] = (byte) 0x43;
+            data[2] = (byte) 0x72;
+            data[3] = (byte) 0x43;
+            data[4] = (byte) 0x00;
+            data[5] = (byte) 0x37;
+
+            pscb.setBinaryStream(2, new java.io.ByteArrayInputStream(data), 6);
+        }
+        pscb.setCharacterStream(3, new java.io.StringReader("72"), 2);
+        pscb.executeUpdate();
+        scb.close();
+        pscb.close();
+        conn.commit();
+
+    }
+
+    public void testParameterMapping() throws Exception {
+        Connection conn = getConnection();
+
+        for (int type = 0; type < SQLTypes.length; type++) {
+
+            String sqlType = SQLTypes[type];
+
+            if (sqlType == null || jdbcTypes[type] == Types.NULL) {
+                    continue;
+            }
+
+            Statement s = conn.createStatement();
+
+            s.execute("CREATE TABLE PM.TYPE_AS(VAL " + SQLTypes[type] + ")");
+
+            PreparedStatement psi = conn
+                    .prepareStatement("INSERT INTO PM.TYPE_AS(VAL) VALUES(?)");
+            psi.setNull(1, jdbcTypes[type]);
+            psi.executeUpdate();
+
+            PreparedStatement psq = conn
+                    .prepareStatement("SELECT VAL FROM PM.TYPE_AS");
+            ResultSet rs = psq.executeQuery();
+            ResultSetMetaData rsmd = rs.getMetaData();
+            assertEquivalentDataType(jdbcTypes[type], rsmd.getColumnType(1));
+            rs.close();
+            // For this data type
+            // Test inserting a NULL value and then performing all the getXXX()
+            // calls on it.
+
+            // System.out.println(" NULL VALUE");
+            getXXX(psq, type, true);
+
+           s.execute("DELETE FROM PM.TYPE_AS");
+
+           // For this data type
+           // Test inserting a valid value and then performing all the getXXX() calls on it.
+           if (setValidValue(psi, 1, jdbcTypes[type])) {
+               psi.executeUpdate();
+               getXXX(psq, type, false);
+           }
+
+            psi.close();
+            psq.close();
+            s.execute("DROP TABLE PM.TYPE_AS");
+            conn.commit();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.derbyTesting.junit.BaseJDBCTestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        rollback();
+        Statement scb = createStatement();
+        scb.execute("DROP TABLE PM.LOB_GET");
+        scb.close();
+
+    }
+
+    private static void getXXX(PreparedStatement ps, int type, boolean isNull)
+            throws SQLException, java.io.IOException {
+
+        {
+            // getByte();
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                byte b = rs.getByte(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue(wn);
+                } else {
+                    assertFalse(wn);
+                    assertEquals(32,b);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 0, type);
+        }
+
+        {
+            // getShort()
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            try {
+                short s = rs.getShort(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue(wn);
+                } else {
+                    assertFalse(wn);
+                    assertEquals(32,s);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 1, type);
+        }
+
+        {
+            //getInt()
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                int i = rs.getInt(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue( wn);
+                } else {
+                    assertFalse(isNull);
+                    assertEquals(32, i);
+                }    
+                worked = true;
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 2, type);
+        }
+
+        {
+            //getLong();
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                long l = rs.getLong(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue(wn);                   
+                }
+                else { 
+                    assertEquals(32,l);
+                    assertFalse(wn);
+                }
+                    worked = true;
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 3, type);
+        }
+
+        {
+            // getFloat()
+           
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            try {
+                float f = rs.getFloat(1);
+                boolean wn = rs.wasNull();
+            
+                if (isNull) {
+                    assertTrue(wn);
+                } else {
+                    assertFalse(wn);
+                    assertEquals(32.0,rs.getFloat(1),.000001);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 4, type);
+        }
+
+        {
+            //getDouble();
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                double d = rs.getDouble(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue(wn);
+                } else {
+                    assertFalse(wn);
+                    assertEquals(32.0,d,.00001);
+                }
+                worked = true;
+           
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 5, type);
+        }
+
+        if (HAVE_BIG_DECIMAL) {
+            //  getBigDecimal()
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                BigDecimal bd = rs.getBigDecimal(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue(wn);
+                    assertNull(bd);
+                }else {
+                    assertFalse(wn);
+                    assertEquals("BigDecimal comparison failed",0, new BigDecimal("32.0").compareTo(bd));
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 6, type);
+        }
+
+        {
+            //getBoolean()
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                boolean b = rs.getBoolean(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertTrue(wn);                    
+                } else {
+                    assertFalse(wn);
+                    assertTrue(b);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 7, type);
+        }
+
+        {
+            // getString()
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                String s = rs.getString(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertNull(s);
+                    assertTrue(wn);
+                }else {
+                    //RESOLVE: Need better check
+                    assertNotNull(s);
+                    assertFalse(wn);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 8, type);
+        }
+
+        {
+            // getBytes()
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                byte[] data = rs.getBytes(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertNull(data);
+                    assertTrue(wn);
+                }else {
+                    //RESOLVE: Need better check
+                    assertNotNull(data);
+                    assertFalse(wn);
+                }
+                worked = true;
+                
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            judge_getXXX(worked, sqleResult, 9, type);
+        }
+
+        {
+            // getDate()
+         
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            ResultSet rs = null;
+            try {
+                rs = ps.executeQuery();
+                rs.next();
+                Date d= rs.getDate(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertNull(d);
+                    assertTrue(wn);
+                } else { 
+                    assertEquals("2004-02-14",d.toString());
+                    assertNotNull(d);
+                    assertFalse(wn);
+                }               
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                // 22007 invalid date time conversion
+                worked = "22007".equals(sqle.getSQLState());
+                if (worked)
+                    System.out.print(sqle.getSQLState());
+            } catch (Throwable t) {
+                System.out.print(t.toString());
+                worked = false;
+            }
+            if (rs != null)
+                rs.close();
+            judge_getXXX(worked, sqleResult, 10, type);
+        }
+
+        {
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            ResultSet rs = null;
+            try {
+                // getTime()
+                rs = ps.executeQuery();
+                rs.next();
+                Time t = rs.getTime(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertNull(t);
+                    assertTrue(wn);
+                } else {
+                    assertFalse(wn);
+                    assertEquals("17:14:24",t.toString());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                // 22007 invalid date time conversion
+                worked = "22007".equals(sqle.getSQLState());
+            } catch (Throwable t) {
+                System.out.println(t);
+                worked = false;
+            }
+            if (rs != null)
+                rs.close();
+            judge_getXXX(worked, sqleResult, 11, type);
+        }
+
+        {
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            ResultSet rs = null;
+            try {
+                //getTimestamp();
+                rs = ps.executeQuery();
+                rs.next();
+                Timestamp ts = rs.getTimestamp(1);
+                boolean wn = rs.wasNull();
+                if (isNull) {
+                    assertNull(ts);
+                    assertTrue(wn);
+                } else {
+                    if (type == java.sql.Types.DATE)
+                        assertEquals("2004-02-14 00:00:00.0",ts.toString());
+                    else if (type == java.sql.Types.TIMESTAMP)
+                        assertEquals("2004-02-23 17:14:24.097625551", ts.toString());
+                    assertFalse(rs.wasNull());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                // 22007 invalid date time conversion
+                worked = "22007".equals(sqle.getSQLState());
+                } catch (Throwable t) {
+                System.out.println(t);    
+                worked = false;
+            }
+            if (rs != null)
+                rs.close();
+            judge_getXXX(worked, sqleResult, 12, type);
+        }
+
+        {
+            System.out.print("  getAsciiStream=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                InputStream is = rs.getAsciiStream(1);
+                // if the value is NULL speific checks are performed below.
+                if (!isNull || B6[13][type]) {
+                    System.out.print(is == null ? "null" : ParameterMappingTest
+                            .showFirstTwo(is));
+                    System.out.print(" was null " + rs.wasNull());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+
+            // getAsciiStream on a NULL value for an invalid conversion
+            // is handled differently in JCC to Cloudscape. On a non-NULL
+            // value an exception is correctly raised by both JCC and CS.
+            // here we check this specific case to reduce canon differences
+            // between CNS and CS.
+
+            boolean judge = B6[13][type]
+                    || specificCheck(rs, worked, sqleResult, isNull);
+            rs.close();
+            if (judge)
+                judge_getXXX(worked, sqleResult, 13, type);
+        }
+
+        {
+            System.out.print("  getBinaryStream=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                InputStream is = rs.getBinaryStream(1);
+                if (!isNull || B6[14][type]) {
+                    System.out.print(is == null ? "null" : ParameterMappingTest
+                            .showFirstTwo(is));
+                    System.out.print(" was null " + rs.wasNull());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            boolean judge = B6[14][type]
+                    || specificCheck(rs, worked, sqleResult, isNull);
+            rs.close();
+            if (judge)
+                judge_getXXX(worked, sqleResult, 14, type);
+        }
+
+        {
+            System.out.print("  getCharacterStream=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                Reader r = rs.getCharacterStream(1);
+                if (!isNull || B6[15][type]) {
+                    System.out.print(r == null ? "null" : ParameterMappingTest
+                            .showFirstTwo(r));
+                    System.out.print(" was null " + rs.wasNull());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            boolean judge = B6[15][type]
+                    || specificCheck(rs, worked, sqleResult, isNull);
+            rs.close();
+            if (judge)
+                judge_getXXX(worked, sqleResult, 15, type);
+        }
+
+        {
+            System.out.print("  getClob=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                Clob clob = rs.getClob(1);
+                if (!isNull || B6[16][type]) {
+                    System.out.print(clob == null ? "null" : clob.getSubString(
+                            1, 10));
+                    System.out.print(" was null " + rs.wasNull());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            boolean judge = B6[16][type]
+                    || specificCheck(rs, worked, sqleResult, isNull);
+            rs.close();
+            if (judge)
+                judge_getXXX(worked, sqleResult, 16, type);
+        }
+
+        {
+            System.out.print("  getBlob=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                Blob blob = rs.getBlob(1);
+                if (!isNull || B6[17][type]) {
+                    System.out.print(blob == null ? "null"
+                            : ParameterMappingTest.showFirstTwo(blob
+                                    .getBinaryStream()));
+                    System.out.print(" was null " + rs.wasNull());
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            boolean judge = B6[17][type]
+                    || specificCheck(rs, worked, sqleResult, isNull);
+            rs.close();
+            if (judge)
+                judge_getXXX(worked, sqleResult, 17, type);
+        }
+
+        {
+            System.out.print("  getUnicodeStream=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            boolean worked;
+            SQLException sqleResult = null;
+            ;
+            try {
+                InputStream is = rs.getUnicodeStream(1);
+                System.out.print(is == null ? "null" : "data");
+                System.out.print(" was null " + rs.wasNull());
+                worked = true;
+            } catch (NoSuchMethodError e) {
+                worked = true;
+                System.out
+                        .println("ResultSet.getUnicodeStream not present - correct for JSR169");
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            rs.close();
+            if (TestUtil.HAVE_DRIVER_CLASS)
+                judge_getXXX(worked, sqleResult, 18, type);
+        }
+
+        // Check to see getObject returns the correct type
+        {
+            System.out.print("  getObject=");
+            ResultSet rs = ps.executeQuery();
+            rs.next();
+            SQLException sqleResult = null;
+            ;
+            try {
+
+                String msg;
+                if (!SQLTypes[type].equals("DECIMAL(10,5)") || HAVE_BIG_DECIMAL) {
+                    Object o = rs.getObject(1);
+
+                    Class cgo = B3_GET_OBJECT[type];
+
+                    String cname;
+                    if (cgo.equals(byte[].class))
+                        cname = "byte[]";
+                    else
+                        cname = cgo.getName();
+
+                    if (o == null) {
+                        msg = "null";
+                    } else if (cgo.isInstance(o)) {
+                        msg = "CORRECT :" + cgo.getName();
+                    } else {
+                        msg = "FAIL NOT :" + cgo.getName() + " is "
+                                + o.getClass().getName();
+                    }
+                } else {
+                    msg = "ResultSet.getObject not called for DECIMAL type for JSR169";
+                }
+
+                System.out.print(msg);
+                System.out.println(" was null " + rs.wasNull());
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+            }
+            rs.close();
+        }
+
+    }
+
+    private static boolean specificCheck(ResultSet rs, boolean worked,
+            SQLException sqleResult, boolean isNull) throws SQLException {
+        boolean judge = true;
+        if (worked && isNull && rs.wasNull()) {
+            // JCC returns NULL
+            if (usingDerbyNetClient())
+                judge = false;
+        } else if (!worked && isNull) {
+            if (usingDerbyNetClient()
+                    && "22005".equals(sqleResult.getSQLState()))
+                judge = false;
+        }
+        if (!judge)
+            System.out.println("SPECIFIC CHECK OK");
+
+        return judge;
+    }
+
+    private static void judge_getXXX(boolean worked, SQLException sqleResult,
+            int whichCall, int type) {
+       boolean validSQLState=false;
+        // verify valid conversion worked
+        if (B6[whichCall][type] && !worked)
+            fail(" JDBC FAIL " + SQLTypes[type] + " " + sqleResult);
+        else if (!worked) {
+            // make sure not implemented or conversion error was thrown if it didn't work
+            String sqlState = sqleResult.getSQLState();
+            if ("0A000".equals(sqlState))
+                validSQLState = true;
+            if ("0A000".equals(sqlState))
+                validSQLState = true;
+            if ("22005".equals(sqlState))
+                // embedded invalid conversion error
+                validSQLState = true;
+            else if (sqlState == null) {
+                // client invalid conversion error
+                if (sqleResult.getMessage().indexOf(
+                        "Wrong result column type for requested conversion") != -1)
+                    validSQLState = true;
+            }
+            assertTrue("FAIL: Expected conversion error but got "
+                        + sqleResult, validSQLState);
+           
+        }
+
+    }
+
+    private static void judge_setXXX(boolean worked, SQLException sqleResult,
+            int whichCall, int type) {
+        String msg;
+        if (worked && B2_MOD[whichCall][type])
+            msg = " JDBC MATCH(OK)";
+        else if (worked)
+            msg = " CLOUD EXT (OK)";
+        else if (B2_MOD[whichCall][type]) {
+            if (sqleResult != null)
+                showException(sqleResult);
+            msg = " JDBC FAIL " + SQLTypes[type];
+        } else {
+            msg = checkForInvalidConversion(sqleResult);
+            if (msg == null)
+                return;
+        }
+
+        System.out.println(msg);
+    }
+
+    private static void judge_setObject(boolean worked,
+            SQLException sqleResult, int b5o, int type) {
+        String msg;
+        if (worked && B5[b5o][type])
+            msg = " JDBC MATCH(OK)";
+        else if (worked)
+            msg = " CLOUD EXT (OK)";
+        else if (B5[b5o][type]) {
+            if (sqleResult != null)
+                showException(sqleResult);
+            msg = " JDBC FAIL " + SQLTypes[type];
+        } else {
+            msg = checkForInvalidConversion(sqleResult);
+            if (msg == null)
+                return;
+        }
+
+        System.out.println(msg);
+    }
+
+    /**
+     * Look for an "Invalid Conversion" exception and format it for display.
+     * 
+     * Look for an "Invalid Conversion" exception. If one is found, print "IC".
+     * If one is not found, dump the actual exception to the output instead.
+     * 
+     * Note that the actual invalid conversion exception may be wrapped inside a
+     * BatchUpdateException, so we may need to hunt through the exception chain
+     * to find it.
+     */
+    private static String checkForInvalidConversion(SQLException sqle) {
+        if (sqle == null)
+            return null;
+
+        boolean unknownException = true;
+        SQLException e = sqle;
+        while (e != null && unknownException == true) {
+            // XCL12 is temp
+            if ("22005".equals(e.getSQLState())
+                    || "XCL12".equals(e.getSQLState())
+                    || e.getMessage().indexOf("Illegal Conv") != -1) {
+                unknownException = false;
+                System.out.print("IC");
+                break;
+            }
+            e = e.getNextException();
+        }
+        if (unknownException)
+            showException(sqle);
+
+        return " JDBC MATCH (INVALID)";
+    }
+
+    private static void setXXX(Statement s, PreparedStatement psi,
+            PreparedStatement psq, int type) throws SQLException,
+            java.io.IOException {
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setByte() ");
+                psi.setByte(1, (byte) 98);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 0, type);
+        }
+        // and as a batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setByte() as batch ");
+                psi.setByte(1, (byte) 98);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 0, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setShort() ");
+                psi.setShort(1, (short) 98);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 1, type);
+        }
+        // and as a batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setShort() as batch ");
+                psi.setShort(1, (short) 98);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 1, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setInt() ");
+                psi.setInt(1, 98);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 2, type);
+        }
+        // and as a batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setInt() as batch ");
+                psi.setInt(1, 98);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 2, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setLong() ");
+                psi.setLong(1, 98L);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 3, type);
+        }
+        // as a batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setLong() as batch ");
+                psi.setLong(1, 98L);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 3, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setFloat() ");
+                psi.setFloat(1, 98.4f);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 4, type);
+        }
+
+        // and as a batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setFloat() as batch ");
+                psi.setFloat(1, 98.4f);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 4, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setDouble() ");
+                psi.setDouble(1, 98.5);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 5, type);
+        }
+
+        // as a batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setDouble() as batch ");
+                psi.setDouble(1, 98.5);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 5, type);
+        }
+
+        if (HAVE_BIG_DECIMAL) {
+            {
+                s.execute("DELETE FROM PM.TYPE_AS");
+
+                SQLException sqleResult = null;
+                boolean worked;
+                try {
+                    System.out.print("  setBigDecimal() ");
+                    psi.setBigDecimal(1, new BigDecimal(99.0));
+                    psi.executeUpdate();
+
+                    getValidValue(psq, jdbcTypes[type]);
+
+                    worked = true;
+
+                } catch (SQLException sqle) {
+                    sqleResult = sqle;
+                    worked = false;
+                }
+                judge_setXXX(worked, sqleResult, 6, type);
+            }
+            // as a batch
+            {
+                s.execute("DELETE FROM PM.TYPE_AS");
+
+                SQLException sqleResult = null;
+                boolean worked;
+                try {
+                    System.out.print("  setBigDecimal() as batch ");
+                    psi.setBigDecimal(1, new BigDecimal(99.0));
+                    psi.addBatch();
+                    psi.executeBatch();
+
+                    getValidValue(psq, jdbcTypes[type]);
+
+                    worked = true;
+
+                } catch (SQLException sqle) {
+                    sqleResult = sqle;
+                    worked = false;
+                }
+                judge_setXXX(worked, sqleResult, 6, type);
+            }
+            // null BigDecimal
+            {
+                s.execute("DELETE FROM PM.TYPE_AS");
+
+                SQLException sqleResult = null;
+                boolean worked;
+                try {
+                    System.out.print("  setBigDecimal(null) ");
+                    psi.setBigDecimal(1, null);
+                    psi.executeUpdate();
+
+                    getValidValue(psq, jdbcTypes[type]);
+
+                    worked = true;
+
+                } catch (SQLException sqle) {
+                    sqleResult = sqle;
+                    worked = false;
+                }
+                judge_setXXX(worked, sqleResult, 6, type);
+            }
+
+            // null BigDecimal
+            {
+                s.execute("DELETE FROM PM.TYPE_AS");
+
+                SQLException sqleResult = null;
+                boolean worked;
+                try {
+                    System.out.print("  setBigDecimal(null) as batch ");
+                    psi.setBigDecimal(1, null);
+                    psi.addBatch();
+                    psi.executeBatch();
+
+                    getValidValue(psq, jdbcTypes[type]);
+
+                    worked = true;
+
+                } catch (SQLException sqle) {
+                    sqleResult = sqle;
+                    worked = false;
+                }
+                judge_setXXX(worked, sqleResult, 6, type);
+            }
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBoolean() ");
+                psi.setBoolean(1, true);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 7, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBoolean() as batch ");
+                psi.setBoolean(1, true);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 7, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setString() ");
+                psi.setString(1, "97");
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            } catch (Throwable t) {
+                // JCC has some bugs
+                System.out.println(t.getMessage());
+                worked = false;
+                sqleResult = null;
+
+            }
+            judge_setXXX(worked, sqleResult, 8, type);
+        }
+        // as batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setString() as batch ");
+                psi.setString(1, "97");
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            } catch (Throwable t) {
+                // JCC has some bugs
+                System.out.println(t.getMessage());
+                worked = false;
+                sqleResult = null;
+
+            }
+            judge_setXXX(worked, sqleResult, 8, type);
+        }
+
+        // null String
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setString(null) ");
+                psi.setString(1, null);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            } catch (Throwable t) {
+                // JCC has some bugs
+                System.out.println(t.getMessage());
+                worked = false;
+                sqleResult = null;
+
+            }
+            judge_setXXX(worked, sqleResult, 8, type);
+        }
+        // null String as batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setString(null) as batch ");
+                psi.setString(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            } catch (Throwable t) {
+                // JCC has some bugs
+                System.out.println(t.getMessage());
+                worked = false;
+                sqleResult = null;
+
+            }
+            judge_setXXX(worked, sqleResult, 8, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            // Set Invalid String for nonString types (DERBY-149)
+            testSetStringInvalidValue(type, psi);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBytes() ");
+                byte[] data = { (byte) 0x04, (byte) 0x03, (byte) 0xfd,
+                        (byte) 0xc3, (byte) 0x73 };
+                psi.setBytes(1, data);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 9, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBytes() as batch");
+                byte[] data = { (byte) 0x04, (byte) 0x03, (byte) 0xfd,
+                        (byte) 0xc3, (byte) 0x73 };
+                psi.setBytes(1, data);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 9, type);
+        }
+        // null byte[]
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBytes(null) ");
+                psi.setBytes(1, null);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 9, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBytes(null) as batch");
+                psi.setBytes(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 9, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setDate() ");
+                psi.setDate(1, java.sql.Date.valueOf("2004-02-14"));
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 10, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setDate() as batch ");
+                psi.setDate(1, java.sql.Date.valueOf("2004-02-14"));
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 10, type);
+        }
+        // null Date
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setDate(null) ");
+                psi.setDate(1, null);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 10, type);
+        }
+
+        // null Date
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setDate(null) as batch ");
+                psi.setDate(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 10, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTime() ");
+                psi.setTime(1, java.sql.Time.valueOf("13:26:42"));
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 11, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTime() as batch ");
+                psi.setTime(1, java.sql.Time.valueOf("13:26:42"));
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 11, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTime(null) ");
+                psi.setTime(1, null);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 11, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTime(null) as batch ");
+                psi.setTime(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 11, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTimestamp() ");
+                psi.setTimestamp(1, java.sql.Timestamp
+                        .valueOf("2004-02-23 17:14:24.097625551"));
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 12, type);
+        }
+        // as batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTimestamp() as batch ");
+                psi.setTimestamp(1, java.sql.Timestamp
+                        .valueOf("2004-02-23 17:14:24.097625551"));
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 12, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTimestamp(null) ");
+                psi.setTimestamp(1, null);
+                psi.executeUpdate();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 12, type);
+        }
+        // as batch
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setTimestamp(null) as batch ");
+                psi.setTimestamp(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 12, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setAsciiStream() ");
+                byte[] data = new byte[6];
+                data[0] = (byte) 0x65;
+                data[1] = (byte) 0x67;
+                data[2] = (byte) 0x30;
+                data[3] = (byte) 0x31;
+                data[4] = (byte) 0x32;
+                data[5] = (byte) 0x64;
+
+                psi
+                        .setAsciiStream(1, new java.io.ByteArrayInputStream(
+                                data), 6);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 13, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setAsciiStream() as batch ");
+                byte[] data = new byte[6];
+                data[0] = (byte) 0x65;
+                data[1] = (byte) 0x67;
+                data[2] = (byte) 0x30;
+                data[3] = (byte) 0x31;
+                data[4] = (byte) 0x32;
+                data[5] = (byte) 0x64;
+
+                psi
+                        .setAsciiStream(1, new java.io.ByteArrayInputStream(
+                                data), 6);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 13, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setAsciiStream(null) ");
+                psi.setAsciiStream(1, null, 0);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 13, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setAsciiStream(null) as batch ");
+                psi.setAsciiStream(1, null, 0);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 13, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBinaryStream() ");
+                byte[] data = new byte[6];
+                data[0] = (byte) 0x82;
+                data[1] = (byte) 0x43;
+                data[2] = (byte) 0xca;
+                data[3] = (byte) 0xfe;
+                data[4] = (byte) 0x00;
+                data[5] = (byte) 0x32;
+
+                psi.setBinaryStream(1, new java.io.ByteArrayInputStream(data),
+                        6);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 14, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBinaryStream() as batch ");
+                byte[] data = new byte[6];
+                data[0] = (byte) 0x82;
+                data[1] = (byte) 0x43;
+                data[2] = (byte) 0xca;
+                data[3] = (byte) 0xfe;
+                data[4] = (byte) 0x00;
+                data[5] = (byte) 0x32;
+
+                psi.setBinaryStream(1, new java.io.ByteArrayInputStream(data),
+                        6);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 14, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBinaryStream(null) ");
+                psi.setBinaryStream(1, null, 0);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 14, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBinaryStream(null) as batch ");
+                psi.setBinaryStream(1, null, 0);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 14, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setCharacterStream() ");
+                psi.setCharacterStream(1, new java.io.StringReader("89"), 2);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 15, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setCharacterStream() as batch ");
+                psi.setCharacterStream(1, new java.io.StringReader("89"), 2);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 15, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setCharacterStream(null) ");
+                psi.setCharacterStream(1, null, 0);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 15, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setCharacterStream(null) as batch ");
+                psi.setCharacterStream(1, null, 0);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 15, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setClob() ");
+
+                ResultSet rsc = s
+                        .executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1");
+                rsc.next();
+                Clob tester = rsc.getClob(1);
+                rsc.close();
+
+                psi.setClob(1, tester);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 16, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setClob() as batch ");
+
+                ResultSet rsc = s
+                        .executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1");
+                rsc.next();
+                Clob tester = rsc.getClob(1);
+                rsc.close();
+
+                psi.setClob(1, tester);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 16, type);
+        }
+
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setClob(null) ");
+
+                psi.setClob(1, null);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 16, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setClob(null) as batch ");
+
+                psi.setClob(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 16, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBlob() ");
+
+                ResultSet rsc = s
+                        .executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1");
+                rsc.next();
+                Blob tester = rsc.getBlob(1);
+                rsc.close();
+
+                psi.setBlob(1, tester);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 17, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBlob() as batch ");
+
+                ResultSet rsc = s
+                        .executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1");
+                rsc.next();
+                Blob tester = rsc.getBlob(1);
+                rsc.close();
+
+                psi.setBlob(1, tester);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 17, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBlob(null) ");
+
+                psi.setBlob(1, null);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 17, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setBlob(null) as batch ");
+
+                psi.setBlob(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            judge_setXXX(worked, sqleResult, 17, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setUnicodeStream() ");
+                byte[] data = new byte[6];
+                data[0] = (byte) 0x82;
+                data[1] = (byte) 0x43;
+                data[2] = (byte) 0xca;
+                data[3] = (byte) 0xfe;
+                data[4] = (byte) 0x00;
+                data[5] = (byte) 0x32;
+
+                try {
+                    psi.setUnicodeStream(1, new java.io.ByteArrayInputStream(
+                            data), 6);
+                } catch (NoSuchMethodError e) {
+                    System.out
+                            .println("ResultSet.setUnicodeStream not present - correct for JSR169");
+                }
+
+                if (TestUtil.HAVE_DRIVER_CLASS) {
+                    psi.executeUpdate();
+                    getValidValue(psq, jdbcTypes[type]);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            if (TestUtil.HAVE_DRIVER_CLASS)
+                judge_setXXX(worked, sqleResult, 14, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setUnicodeStream(null) ");
+                try {
+                    psi.setUnicodeStream(1, null, 0);
+                } catch (NoSuchMethodError e) {
+                    System.out
+                            .println("ResultSet.setUnicodeStream not present - correct for JSR169");
+                }
+
+                if (TestUtil.HAVE_DRIVER_CLASS) {
+                    psi.executeUpdate();
+                    getValidValue(psq, jdbcTypes[type]);
+                }
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            if (TestUtil.HAVE_DRIVER_CLASS)
+                judge_setXXX(worked, sqleResult, 14, type);
+        }
+
+        // setObject(null)
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                // should never work!
+                System.out.print("  setObject(null) ");
+                psi.setObject(1, null);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            System.out.println(worked ? " FAIL " : (" OK " + sqleResult
+                    .getMessage()));
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                // should never work!
+                System.out.print("  setObject(null) as batch ");
+                psi.setObject(1, null);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            }
+            System.out.println(worked ? " FAIL " : (" OK " + sqleResult
+                    .getMessage()));
+        }
+
+        setXXX_setObject(s, psi, psq, type, "46", "java.lang.String", 0);
+        if (HAVE_BIG_DECIMAL)
+            setXXX_setObject(s, psi, psq, type, BigDecimal.valueOf(72L),
+                    "java.math.BigDecimal", 1);
+        setXXX_setObject(s, psi, psq, type, Boolean.TRUE, "java.lang.Boolean",
+                2);
+
+        // DERBY-1500: setObject() should work for Byte and Short too.
+        setXXX_setObject(s, psi, psq, type, new Byte((byte) 2),
+                "java.lang.Byte", 13);
+        setXXX_setObject(s, psi, psq, type, new Short((short) 11),
+                "java.lang.Short", 14);
+
+        setXXX_setObject(s, psi, psq, type, new Integer(74),
+                "java.lang.Integer", 3);
+        setXXX_setObject(s, psi, psq, type, new Long(79), "java.lang.Long", 4);
+        setXXX_setObject(s, psi, psq, type, new Float(76.3f),
+                "java.lang.Float", 5);
+        setXXX_setObject(s, psi, psq, type, new Double(12.33d),
+                "java.lang.Double", 6);
+
+        {
+            byte[] data = { 0x32, 0x39 };
+            setXXX_setObject(s, psi, psq, type, data, "byte[]", 7);
+        }
+
+        setXXX_setObject(s, psi, psq, type,
+                java.sql.Date.valueOf("2004-02-14"), "java.sql.Date", 8);
+        setXXX_setObject(s, psi, psq, type, java.sql.Time.valueOf("13:26:42"),
+                "java.sql.Time", 9);
+        setXXX_setObject(s, psi, psq, type, java.sql.Timestamp
+                .valueOf("2004-02-23 17:14:24.097625551"),
+                "java.sql.Timestamp", 10);
+        s.getConnection().commit();
+
+        if (!usingDerbyNetClient()) {
+            {
+                ResultSet rsc = s
+                        .executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1");
+                rsc.next();
+                Blob tester = rsc.getBlob(1);
+                rsc.close();
+                setXXX_setObject(s, psi, psq, type, tester, "java.sql.Blob", 11);
+            }
+
+            {
+                ResultSet rsc = s
+                        .executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1");
+                rsc.next();
+                Clob tester = rsc.getClob(1);
+                rsc.close();
+                setXXX_setObject(s, psi, psq, type, tester, "java.sql.Clob", 12);
+            }
+        }
+    }
+
+    private static void setXXX_setObject(Statement s, PreparedStatement psi,
+            PreparedStatement psq, int type, Object value, String className,
+            int b5o) throws SQLException, java.io.IOException {
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setObject(" + className + ") ");
+                psi.setObject(1, value);
+                psi.executeUpdate();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            } catch (Throwable t) {
+                System.out.println("FAIL " + t.getMessage());
+                return;
+            }
+            judge_setObject(worked, sqleResult, b5o, type);
+        }
+        {
+            s.execute("DELETE FROM PM.TYPE_AS");
+
+            SQLException sqleResult = null;
+            boolean worked;
+            try {
+                System.out.print("  setObject(" + className + ") as batch ");
+                psi.setObject(1, value);
+                psi.addBatch();
+                psi.executeBatch();
+                getValidValue(psq, jdbcTypes[type]);
+
+                worked = true;
+
+            } catch (SQLException sqle) {
+                sqleResult = sqle;
+                worked = false;
+            } catch (Throwable t) {
+                System.out.println("FAIL " + t.getMessage());
+                return;
+            }
+            judge_setObject(worked, sqleResult, b5o, type);
+        }
+    }
+
+    private static void unexpectedException(SQLException sqle) {
+
+        System.out.print("FAIL unexpected exception - ");
+        showException(sqle);
+        sqle.printStackTrace(System.out);
+    }
+
+    private static void showException(SQLException sqle) {
+        do {
+            String state = sqle.getSQLState();
+            if (state == null)
+                state = "?????";
+

[... 399 lines stripped ...]


Mime
View raw message