IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JDBC Java Discussion :

probleme de JDBCAdapter


Sujet :

JDBC Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 87
    Par défaut probleme de JDBCAdapter
    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
    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);
    
        }
    et voila l'erreur qu'il maffiche
    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

  2. #2
    in
    in est déconnecté
    Membre Expert Avatar de in
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 612
    Par défaut
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 19
    at JDBCAdapter.setValueAt(JDBCAdapter.java:239)
    Tu essaies d'accéder à un objet à l'index 19 d'un tableau qui est surement plus petit que 20. Et ça se passe à la ligne 239 de JDBCAdapter.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 87
    Par défaut
    excusez moi j'ai pas compris est ce que vous pouvez m'expliquer plus
    merci d'avance

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 87
    Par défaut
    en fait le probleme dans cette instruction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     String colName = fieldName[col];
    je sais pas pourquoi ca passe pas seulement pour tables mais pour les autres ca marche bien sacahant que pr ces deux tables jai plus que 20 champs
    merci

  5. #5
    in
    in est déconnecté
    Membre Expert Avatar de in
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 612
    Par défaut
    a mon avis ton tableau fieldName est plus petit que ton nombre de colonnes.

    Comment l'initialises tu ?

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 87
    Par défaut
    voila comment je lai fait je sais pas est ce que c 'est bien ou bien non


+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme de rafraichissement d'un BDGrid
    Par marmotte dans le forum Bases de données
    Réponses: 10
    Dernier message: 28/05/2004, 19h07
  2. Réponses: 2
    Dernier message: 30/05/2002, 09h54
  3. Probleme sur les chaines de caractere
    Par scorpiwolf dans le forum C
    Réponses: 8
    Dernier message: 06/05/2002, 20h01
  4. [Kylix] Probleme d'execution de programmes...
    Par yopziggy dans le forum EDI
    Réponses: 19
    Dernier message: 03/05/2002, 15h50
  5. [Kylix] Probleme de nombre flottant!!
    Par yopziggy dans le forum EDI
    Réponses: 5
    Dernier message: 02/05/2002, 11h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo