title: java.lang.ArrayIndexOutOfBoundsException: 2
body: <p>I'm trying to connect java to sql. Though I'm a newbie with javam I can't seem to find out why.</p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: 2 
  </code></pre>
  
  <p>Can you help me and give me idea how to figure it out?</p>
  
  <pre><code>try{
         Connection con = dbConnection();
  
         String lname = this.last.getText();
         String fname = this.first.getText();
         String mname = this.mid.getText();
         String ad = this.add.getText();
         String bd = this.bday.getText();
         String ag = this.edad.getText();
         String nom = this.no.getText();
         String per = this.person.getText();
  
         String query = "INSERT INTO Personal Category    (Lastname,Firstname,Middle,Address,Birthday,Age,No,Person) VALUES (?,?)"; //to insert to database
  
         PreparedStatement pre;
  
         pre = con.prepareStatement(query);
  
  
         pre.setString(1, lname);
         pre.setString(2, fname);
         pre.setString(3, mname);
         pre.setString(4, ad);
         pre.setString(5, bd);
         pre.setString(6, ag);
         pre.setString(7, nom);
         pre.setString(8, per);
  
  
         pre.execute();//execute
  
         con.close();
  
  
      }catch (Exception e){
  
          System.out.println(e);
  
      }
  
  }
  </code></pre>