title: Big number of values IN Query with ItemReader
body: <p>The following ItemReader gets a list of thousands accounts (<strong>acc</strong>).</p>
  <p>The database that the ItemReader will connected to in order to retrieve the data is HIVE. I don’t have permission to create any table, only read option.</p>
  <pre><code> @Bean
   @StepScope
  public ItemReader&lt;OmsDto&gt; omsItemReader(@Value(&quot;#{stepExecutionContext[acc]}&quot;) List&lt;String&gt; accountList) {
  
      String inParams = String.join(&quot;,&quot;, accountList.stream().map(id -&gt; 
  &quot;'&quot;+id+&quot;'&quot;).collect(Collectors.toList()));
  
      String query = String.format(&quot;SELECT ..... account IN (%s)&quot;, inParams); 
      
      BeanPropertyRowMapper&lt;OmsDto&gt; rowMapper = new BeanPropertyRowMapper&lt;&gt;(OmsDto.class);
      rowMapper.setPrimitivesDefaultedForNullValue(true);
      JdbcCursorItemReader&lt;OmsDto&gt; reader = new JdbcCursorItemReader&lt;OmsDto&gt;();
  
      reader.setVerifyCursorPosition(false);
      reader.setDataSource(hiveDataSource());
      reader.setRowMapper(rowMapper);
      reader.setSql(query);
      reader.open(new ExecutionContext());
      return reader;
  }
  </code></pre>
  <p>This is the error message that I get when using ItemReader:</p>
  <pre><code>Caused by: org.springframework.batch.item.ItemStreamException: Failed to initialize the reader
  at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:153) ~[spring-batch-infrastructure-4.2.4.RELEASE.jar:4.2.4.RELEASE]
  
   Caused by: java.sql.SQLException: Error executing query
  at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:279) ~[presto-jdbc-0.243.2.jar:0.243.2-128118e]
  at com.facebook.presto.jdbc.PrestoStatement.execute(PrestoStatement.java:228) ~[presto-jdbc-0.243.2.jar:0.243.2-128118e]
  at com.facebook.presto.jdbc.PrestoPreparedStatement.&lt;init&gt;(PrestoPreparedStatement.java:84) ~[presto-jdbc-0.243.2.jar:0.243.2-128118e]
  at com.facebook.presto.jdbc.PrestoConnection.prepareStatement(PrestoConnection.java:130) ~[presto-jdbc-0.243.2.jar:0.243.2-128118e]
  at com.facebook.presto.jdbc.PrestoConnection.prepareStatement(PrestoConnection.java:300) ~[presto-jdbc-0.243.2.jar:0.243.2-128118e]
  at org.springframework.batch.item.database.JdbcCursorItemReader.openCursor(JdbcCursorItemReader.java:121) ~[spring-batch-infrastructure-4.2.4.RELEASE.jar:4.2.4.RELEASE]
  ... 63 common frames omitted
  Caused by: java.lang.RuntimeException: Error fetching next at https://prestoanalytics-ch2-p.sys.comcast.net:6443/v1/statement/executing/20201118_131314_11079_v3w47/yf55745951e0beccc234c98f36005723457073854/0 returned an invalid response: JsonResponse{statusCode=502, statusMessage=Bad Gateway, headers={cache-control=[no-cache], content-length=[107], content-type=[text/html]}, hasValue=false} [Error: &lt;html&gt;&lt;body&gt;&lt;h1&gt;502 Bad Gateway&lt;/h1&gt;
  The server returned an invalid or incomplete response.
  &lt;/body&gt;&lt;/html&gt;
  ]
  </code></pre>
  <p>I was sure that the root cause is because of the driver but I have tested the driver with the same SQL this time using DriverManager and its run perfectly.</p>
  <pre><code> @Component
   public class OmsItemReader implements ItemReader&lt;OmsDto&gt;, StepExecutionListener {
  
  private ItemReader&lt;OmsDto&gt; delegate;
  public SikOmsItemReader() {
      
      Properties properties = new Properties();
      properties.setProperty(&quot;user&quot;, &quot;....&quot;);
      properties.setProperty(&quot;password&quot;, &quot;...&quot;);
      properties.setProperty(&quot;SSL&quot;, &quot;true&quot;);
      
      Connection connection = null;
      
      try {
          connection = DriverManager.getConnection(&quot;jdbc:presto://.....&quot;, properties);
          Statement statement = connection.createStatement();
          
          ResultSet resultSet = statement.executeQuery(
  </code></pre>
  <p>I am not sure what is the different ? Is it the driver or sparing batch ?</p>
  <p>I am looking for a workaround. How can I retrieve thousands of accounts via IN clauses with spring batch ?</p>
  <p>Thank you</p>