title: "Invalid data conversion" in DB2 with prepared statements and batch
body: <p>I am using JDBC to create a temporary table, add records to it (with prepared statement and batch) and then transfer everything to another table:</p>
  
  <pre><code>        String createTemporaryTable = "declare global temporary table temp_table (RECORD smallint,RANDOM_INTEGER integer,RANDOM_FLOAT float,RANDOM_STRING varchar(600)) ON COMMIT PRESERVE ROWS in TEMP";
  
          statement.execute(createTemporaryTable);
  
          String sql = "INSERT INTO session.temp_table (RECORD,RANDOM_INTEGER,RANDOM_FLOAT,RANDOM_STRING) VALUES (?,?,?,?)";
          PreparedStatement preparedStatement = connection.prepareStatement(sql);
  
          float f = 0.7401298f;
          Integer integer = 123456789;
          String string = "This is a string that will be inserted into the table over and over again.";
  
          // add however many random records you want to the temporary table
          int numberOfRecordsToInsert = 35000;
  
          for (int i = 0; i &lt; numberOfRecordsToInsert; i++) {
  
              preparedStatement.setInt(1, i);
              preparedStatement.setInt(2, integer);
              preparedStatement.setFloat(3, (float) f);
              preparedStatement.setString(4, string);
              preparedStatement.addBatch();
  
          }
  
          preparedStatement.executeBatch();
  
          // transfer everything from the temporary table just created to the main table
          String transferFromTempTableToMain = "insert into main_table select * from session.temp_table";
          statement.execute(transferFromTempTableToMain);
  </code></pre>
  
  <p>This works fine up to about 30000 records in this example. However, if I were to insert say 35000 records I get the following error:</p>
  
  <blockquote>
    <p>Invalid data conversion: Requested conversion would result in a loss
    of precision of 32768. ERRORCODE=-4461, SQLSTATE=42815</p>
  </blockquote>