title: java.sql.SQLException: Invalid column index
body: <p>I have a SQL query which I want to use to count components into table.</p>
  
  <pre><code>private DCDataObj dc;
  
      public class DCDataObj
      {
  
          private int datacenter;             //  Datacenters
          ..............
  
          public DCDataObj(int datacenter............)
          {
              this.datacenter = datacenter;
              ...............
          }
  
          public int getDatacenter()
          {
              return datacenter;
          }
  
          public void setDatacenter(int datacenter)
          {
              this.datacenter = datacenter;
          }
  
          ............
      }
  
  ps = conn.prepareStatement("SELECT COUNT(1) AS CNT FROM COMPONENTSTATS CS, COMPONENTTYPE CT "
          + " WHERE CS.COMPONENTTYPEID = CT.COMPONENTTYPEID AND CT.COMPONENTTYPEID IN ( "
          + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " //  10
          + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " //  20
          + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " //  30
          + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) " //  40
          + " GROUP BY CT.NAME ORDER BY CT.NAME");
  
  ps.setInt(1, 1000);
  ...............
  
  ResultSet result = ps.executeQuery();
              while (result.next())
              {
  
                  dc = new DCDataObj(
                          result.getInt(1),
                          ...............
  </code></pre>
  
  <p>Here is the complete source code: <a href="http://pastebin.com/YMvqBPpV" rel="nofollow">http://pastebin.com/YMvqBPpV</a></p>
  
  <p>I get this error message: java.sql.SQLException: Invalid column index</p>
  
  <p>Is this design problem or the problem is into the SQL query?</p>