title: How can I prevent this exception? java.sql.SQLException: Fail to convert to internal representation:
body: <p>My code is throwing the above exception on the following line (line 2 of this) : </p>
  
  <pre><code>final ArrayDescriptor tParamArrayDescriptor = ArrayDescriptor.createDescriptor("MY_SYSTEM.T_PARAM_ARRAY", databaseHandler.getConnection());
  final ARRAY oracleArray = new ARRAY(tParamArrayDescriptor, databaseHandler.getConnection(), myObjects.toArray());
  </code></pre>
  
  <p>Its giving me the following exception : </p>
  
  <pre><code>java.sql.SQLException: Fail to convert to internal representation: 
  </code></pre>
  
  <p>The <code>myObjects</code> is an ArrayList of the following POJO:</p>
  
  <pre><code>public class MyObject
  {
      private String name;
      private String surname;
  
      private int age;
  
      ...
  
      // Accessors etc..
  
  }
  </code></pre>
  
  <p>The <code>T_PARAM_ARRAY</code> on the database looks as follows : </p>
  
  <pre><code>create or replace
  TYPE               T_PARAM_ARRAY AS OBJECT (NAME VARCHAR2(50), SURNAME VARCHAR2(50), AGE NUMBER(1));
  </code></pre>
  
  <p>After some research, I believe that the data type mapping between my POJO and the database type don't match up correctly. I'm reasonably confident that String is matching onto VARCHAR2 ok, but I think there is an issue converting the <code>int</code> to a <code>NUMBER</code>.</p>
  
  <p>I've tried using BigDecimal, but that didn't improve the situation.</p>
  
  <p>Any suggestions?</p>
  
  <p>EDIT: According to the <a href="http://download.oracle.com/docs/cd/B10500_01/java.920/a96654/oraarr.htm" rel="noreferrer">Oracle documentation</a> : <code>Where intArray is an oracle.sql.ARRAY, corresponding to a VARRAY of type NUMBER. The values array contains an array of elements of type java.math.BigDecimal, because the SQL NUMBER datatype maps to Java BigDecimal by default, according to the Oracle JDBC drivers.</code></p>