Wednesday, June 26, 2019

java.lang.ArrayIndexOutOfBoundsException: 2

I'm trying to connect java to sql. Though I'm a newbie with javam I can't seem to find out why.



java.lang.ArrayIndexOutOfBoundsException: 2 


Can you help me and give me idea how to figure it out?



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);

}

}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...