bonjour ,
je suis de retour a votre retour car vous mavaez aidé tout le temps merci de votre aide
j'ai un probléme que je l'arrive pas a comprendre c'est que j'arrive avec le meme code de faire la modification par contre ca passe pas pour 2 tables par contre pour les autres tables ca marche bien
voila un morceau de code
et voila l'erreur qu'il maffiche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 public void setValueAt(Object value, int row, int column) { try { String tableName = metaData.getTableName(column+1); // Some of the drivers seem buggy, tableName should not be null. if (tableName == null) { System.out.println("Table name returned null."); } //il s'arrete la je sais pas pourquoi !!!!!!!!!!!!!!!!!! String columnName = fieldName[column]; //getColumnName(column); String query = "update "+tableName+ " set "+columnName+" = "+dbRepresentation(column, value)+ " where "; // We don't have a model of the schema so we don't know the // primary keys or which columns to lock on. To demonstrate // that editing is possible, we'll just lock on everything. for(int col = 0; col<getColumnCount(); col++) { String colName = fieldName[col]; if (colName.equals("")) { continue; } if (col != 0) { query = query + " and "; } query = query + colName +" = "+ dbRepresentation(col, getValueAt(row, col)); } //System.out.println(query); //System.out.println("Not sending update to database"); //statement.executeQuery(query); new MyMsgBox("You are going to Update the line ",win,MyMsgBox.MSG_YESNO,this); switch(mResponse){ case MyMsgBox.RESP_YES: statement.executeUpdate(query); break; default:} //} } catch (SQLException e) { // e.printStackTrace(); System.err.println("Update failed : "+e); } Vector<String> dataRow = rows.elementAt(row); dataRow.setElementAt((String)value.toString(), column); }
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 19
at JDBCAdapter.setValueAt(JDBCAdapter.java:239)
at javax.swing.JTable.setValueAt(Unknown Source)
at javax.swing.JTable.editingStopped(Unknown Source)
at javax.swing.AbstractCellEditor.fireEditingStopped(Unknown Source)
at javax.swing.DefaultCellEditor$EditorDelegate.stopCellEditing(Unknown Source)
at javax.swing.DefaultCellEditor.stopCellEditing(Unknown Source)
at javax.swing.JTable$GenericEditor.stopCellEditing(Unknown Source)
at javax.swing.JTable.editCellAt(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI$Handler.adjustFocusAndSelection(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
merci d'avance de votre aide
Partager