title: Unable to use prepared statement to insert data in partitioned table
body: <p>I am trying to insert data into partitioned impala table using java prepared statements. Insert is working good with non partitioned but I am getting error with partitioned tables. </p>
  
  <p>I need to check performance difference of partitioned vs non partitioned , I feel best would be to use prepared statements for the connection.</p>
  
  <pre><code>
  create_query = "CREATE TABLE IF NOT EXISTS tbl_raw_flow_v9 (source_ip string,destination_ip string,protocol_number int,) partitioned by (year int) stored as parquet";
  
      private static final String sqlCompiledQuery = "INSERT INTO tbl_raw_flow_v9 (source_ip,destination_ip,protocol_number" +
              "PARTITION (year) VALUES (?,?,?,?)";
  
  
      private static Connection connectViaDS() throws Exception {
          Connection connection = null;
  
          Class.forName("com.cloudera.impala.jdbc41.Driver");
  
          connection = DriverManager.getConnection(CONNECTION_URL);
  
          return connection;
  
      }
  
  
  # my try block
  
  try {
              connection = connectViaDS();
  
              connection.setAutoCommit(false);
  
              preparedStatement = connection.prepareStatement(sqlCompiledQuery);
  
              while(counter &lt;total) {
  
                  for (int index = 1; index &lt;= records; index++) {
  
                      counter++;
  
                      preparedStatement.setString(1, "s_ip" + String.valueOf(index));
  
                      preparedStatement.setString(2, "d_ip" + String.valueOf(index));
  
                      preparedStatement.setInt(3, protocol_no + index);
  
                      preparedStatement.setInt(4, yr + flag);
  
                      preparedStatement.addBatch();
  
                  }
                  preparedStatement.executeBatch();
  
                  preparedStatement.clearBatch();
  
                  connection.commit();
  
                  System.out.println("Counter = "+counter);
  
                  flag++;
  
  
              }
  
          } 
  
  </code></pre>
  
  <p>I don't know whether I am making mistake in using prepared statement or there is something else. I am able to insert value into partition table using</p>
  
  <pre><code>"INSERT INTO tbl_raw_flow_v9 (source_ip,destination_ip,protocol_number) PARTITION (year) VALUES ("s_ip","d_ip",234,2010);
  </code></pre>
  
  <p>When I use prepaid statement I get following error in java-</p>
  
  <pre><code>java.sql.SQLException: [Simba][JDBC](11420) Error, parameter metadata not populated.
      at com.cloudera.exceptions.ExceptionConverter.toSQLException(Unknown Source)
      at com.cloudera.jdbc.common.SPreparedStatement.&lt;init&gt;(Unknown Source)
      at com.cloudera.jdbc.common4.C4SPreparedStatement.&lt;init&gt;(Unknown Source)
      at com.cloudera.jdbc.jdbc41.S41PreparedStatement.&lt;init&gt;(Unknown Source)
      at com.cloudera.jdbc.jdbc41.JDBC41ObjectFactory.createPreparedStatement(Unknown Source)
      at com.cloudera.impala.jdbc41.ImpalaJDBC41ObjectFactory.createPreparedStatement(Unknown Source)
      at com.cloudera.jdbc.common.SConnection.prepareStatement(Unknown Source)
      at impala_test.writeInABatchWithCompiledQuery(impala_test.java:100)
      at impala_test.main(impala_test.java:52)
  </code></pre>
  
  <p>It would be really helpful if someone can throw light on this.</p>