Tengo el Siguiente Codigo:
void jButton1_actionPerformed(ActionEvent e) {
try
{
Connection c;
PreparedStatement ps;
ResultSet rs;
String str = "jdbc:odbc:PEMPLEADO2";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c = DriverManager.getConnection(str);
ps = c.prepareStatement("Select * From EMPLEADO");
rs = ps.executeQuery();
while (rs.next())
{
Object[] fila = new Object[5];
for (int i = 0; i < 5; i++)
{
fila[i] = rs.getObject(i + 1);
}
datos.addRow(fila);
}
}
catch (Exception es) {
es.printStackTrace();
}
TableColumn columna2 = jTable1.getColumnModel().getColumn(5);
columna2.setCellRenderer(jTable1.getDefaultRendere r(Boolean.class));
columna2.setCellEditor(jTable1.getDefaultEditor(Bo olean.class));
int m2=datos.getRowCount();
int m1=datos.getColumnCount()-1;
for (int j = 0; j < m2; j++)
{
for (int i = 0; i < m1; i++)
{
v.add(datos.getValueAt(i, j));
//v.add(datos.getDataVector().elementAt(j));
}
}
}
Donde en mi tabla de mi aplicacion tengo 6 columnas.
Cuando hago click en el boton para que muestre los registros de mi base de datos que son 7 en mi tabla de mi aplicacion me sale el siguiente mensaje:
java.lang.ArrayIndexOutOfBoundsException: 6 >= 6
at java.util.Vector.elementAt(Vector.java:431)
at javax.swing.table.DefaultTableModel.getValueAt(Def aultTableModel.java:618)
at sintitulo6.Marco1.jButton1_actionPerformed(Marco1. java:389)
at sintitulo6.Marco1_jButton1_actionAdapter.actionPer formed(Marco1.java:710)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.act ionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.jav a:5100)
at java.awt.Component.processEvent(Component.java:489 7)
at java.awt.Container.processEvent(Container.java:156 9)
at java.awt.Component.dispatchEventImpl(Component.jav a:3615)
at java.awt.Container.dispatchEventImpl(Container.jav a:1627)
at java.awt.Component.dispatchEvent(Component.java:34 77)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3128)
at java.awt.Container.dispatchEventImpl(Container.jav a:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606 )
at java.awt.Component.dispatchEvent(Component.java:34 77)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 456)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:100)
Porque me sale este p mensaje