title: Pass Array From Java to PLSQL Stored Procedure
body: <p>I am trying to pass Java array 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 code snippet</p>
  
  <pre><code>List projectList = new ArrayList();
  
  public void saveRecord(List&lt;Project&gt; project) 
                         throws DatabaseException,SQLException {
  
      for (Project items: project) {
          insertRecord(items);
      }
  }
  
  private void insertRecord(Project project) throws SQLException {
      projectList.add(project);
  
  callablestatement = 
           (OracleCallableStatement)connection.prepareCall("{call my_proc(?)}");
  
  Object[] project1 = projectList.toArray();
  
  StructDescriptor projectTypeDesc = StructDescriptor.createDescriptor("MY_TYPE",
  conn);
  
  STRUCT structProject1 = new STRUCT(projectTypeDesc, 
  connection, project);
  
  STRUCT[] structArrayOfProjects = {structProject1};
  
   ArrayDescriptor projectTypeArrayDesc = ArrayDescriptor.createDescriptor
  ("MY_ARRAY", connection); 
  
  ARRAY arrayOfProjects = new ARRAY(projectTypeArrayDesc, connection,
  structArrayOfProjects);// error in this line
  
  callablestatement.setArray(1, arrayOfProjects);  
  </code></pre>
  
  <p>How can I resolve this issue?</p>
  
  <p><em>Edit 1</em></p>
  
  <p>If I do as</p>
  
  <pre><code>Object[] project1 = new Object[]{project.getProjectId(), project.getProjectTitle()};
  </code></pre>
  
  <p>then no errors and records are inserted into table.</p>
  
  <p>However if I would do as </p>
  
  <pre><code>Object[] project1 = projectList.toArray();
  </code></pre>
  
  <p>then exception is thrown <code>Inconsistent java and sql object types</code></p>