title: Pass Array of objects From Java to PLSQL Stored Procedure
body: <p>I am trying to pass Java array object to PLSQL stored procedure, however when I am trying to execute, I am getting the following exception</p>
  
  <pre><code>java.sql.SQLException: Inconsistent java and sql object types
  </code></pre>
  
  <p>My Dao Class:</p>
  
  <pre><code>public class UploadTradeDaoImpl implements UploadTradeDao{
  
  private static Logger log = LoggerFactory
          .getLogger(UploadTradeDaoImpl.class);
  private SqlSessionFactory sqlSessionFactory;
  
  public SqlSessionFactory getSqlSessionFactory() {
      return sqlSessionFactory;
  }
  
  public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
      this.sqlSessionFactory = sqlSessionFactory;
  }
  
  public int uploadTrade(List&lt;UploadTrade&gt; uploadTradeList) {
  
      SqlSession session = sqlSessionFactory.openSession();
      try {
          Connection conn = session.getConnection().getMetaData()
                  .getConnection();
          StructDescriptor structDescriptor = StructDescriptor
                  .createDescriptor("UPLOADTRADE_OBJ", conn);
          STRUCT[] testStruct= new STRUCT[uploadTradeList.size()];
          ArrayDescriptor arrayDescriptor= ArrayDescriptor.createDescriptor(
                  "UPLOADTRADE_REC", conn);
          Object[] upload_obj_array = new Object[uploadTradeList.size()];
          for (int index = 0; index &lt; uploadTradeList.size(); index++) {
              UploadTrade uploadTradeObj = uploadTradeList.get(index);
              Object[] uploadObjects = new Object[] {
                      uploadTradeObj.getBusTrdId(),
                      uploadTradeObj.getIntrnlExtl(),
                      uploadTradeObj.getMarsLe(),
                      uploadTradeObj.getLeg1CflwType(),
                       uploadTradeObj.getLeg2CflwType(),
                      uploadTradeObj.getRestmntCode(),
                      uploadTradeObj.getRestmntQtr(),
                      uploadTradeObj.getTrdId()};
              upload_obj_array[index] = new STRUCT(structDescriptor, conn, uploadObjects);
  
          }
          ARRAY obj_array = new ARRAY(arrayDescriptor, conn, upload_obj_array);
  
          CallableStatement callableStatement= conn.prepareCall("call INSERTUPLOADTRADEOBJ(?,?)");
          callableStatement.setArray(1, obj_array);
          callableStatement.registerOutParameter(2, OracleTypes.ARRAY,"UPLOADTRADE_REC");
          callableStatement.execute();
  
  
      } catch (Exception e) {
          e.printStackTrace();
          session.rollback();
          log.error("Error! in UploadTrade()" + e.getMessage());
          return 0;
      } finally {
  
          session.close();
  
      }
      return 1;
  
  }
  </code></pre>
  
  <p>I am doing this using these 2 links:
  <a href="https://community.oracle.com/message/4329339#4329339" rel="nofollow noreferrer">https://community.oracle.com/message/4329339#4329339</a></p>
  
  <p><a href="https://stackoverflow.com/questions/19888520/pass-array-from-java-to-oracle-java-sql-sqlexception-fail-to-convert-to-intern">Pass array from Java to Oracle: java.sql.SQLException: Fail to convert to internal representation:error</a></p>
  
  <p>please let me know what I am doing wrong.</p>
  
  <p>Thanks in Advance</p>