Hy , i read all the other posts about this error but didn`t helped me , tried google but notheing.
I have the following method :
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
DefaultTableModel model = (DefaultTableModel)jTable2.getModel();
int nrrows = jTable2.getSelectedRowCount();
int[] rows = jTable2.getSelectedRows();
System.out.println("randuri selectate " +nrrows);
int j,i;
int col=0;
Object value = new Object();
for(i=0;i<nrrows;i++){
value = model.getValueAt(rows[i] , col);
System.out.print("randul"+rows[i]+" " );
System.out.print( value);
System.out.println(" ");
String connectionURL = "jdbc:mysql://localhost:3306/bazadedate";
Connection connection;
try{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(connectionURL, "root", "123456");
PreparedStatement pst = connection.prepareStatement("DELETE FROM tabel WHERE id="+value);
j = pst.executeUpdate();
model.removeRow(rows[i]);
}
catch(Exception e){
System.out.println("The exception is " + e);
}
}
}
And i keeps throwing me the same error :
"AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 5 >= 4
The task of the button when it`s clicked is to delete from database the records with the id ... .