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 :

[débutant] indice de colonne hors limite


Sujet :

JDBC Java

  1. #1
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut [débutant] indice de colonne hors limite
    salut tout le monde, j'ai d'abord voulu écumer toutes les pages de jdbc pour voir si le souci avait déja été abordé, mais après 13 pages j'ai laché l'affaire, donc si la réponse est déja quelque part sorry. Oui donc alors je veux récupérer le contenu de ma base de données pour l'afficher dans un JTextArea, en indiquant une précision pour la recherche, genre un mot clé. le JTextArea marche nikel le souci vient de ma méthode select , mais la je patauge vraiment, s'il vous plait help me ,voila ma méthode :
    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
     
    select_date = connect.prepareStatement         ("select annee,numero,adresse,prix,genre,datevente,idquartier,note from bienvendus where datevente='?'" );
     
    public ArrayList<BiensVendus> dateVente(String date) {
      ArrayList<BiensVendus> an = new ArrayList<BiensVendus>();
        try{
             select_date.setString(1,date);
            ResultSet rs = select_date.executeQuery();
     
            int i= 0;
     
            while(rs.next()){
     
            an.add(i,new BiensVendus(rs.getInt("annee"),rs.getString("numero"),rs.getString("adresse"),rs.getInt("prix"),rs.getString("genre"),date,rs.getInt("idQuartier"),rs.getString("note")));
            i++;
     
                }
     
            } 
            catch(SQLException e){e.printStackTrace();}
            System.out.println("an");
     
            return an;
        }
    et voila l'erreur :

    org.postgresql.util.PSQLException: L'indice de la colonne est hors limite*: 1, nombre de colonnes*: 0.

    svp aidez moi je commence a désespérer

  2. #2
    Membre régulier
    Inscrit en
    Janvier 2007
    Messages
    146
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 146
    Points : 93
    Points
    93
    Par défaut
    s'il te plait peux tu mettre ton code dans des balises de code parce qu'on est vendredi et je n'y vois plus tres clair

  3. #3
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Citation Envoyé par lerab51 Voir le message
    s'il te plait peux tu mettre ton code dans des balises de code parce qu'on est vendredi et je n'y vois plus tres clair
    +1 est donne la stack de l'exception au complet stp.

  4. #4
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    désolé , donc voila ma déclaration

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    select_date = connect.prepareStatement ("select annee,numero,adresse,prix,genre,datevente,idquartier,note from bienvendus where datevente='?'" );
    voila le code de ma méthode

    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
    public ArrayList<BiensVendus> dateVente(String date) {
    ArrayList<BiensVendus> an = new ArrayList<BiensVendus>();
    try{
    select_date.setString(1,date);
    ResultSet rs = select_date.executeQuery();
     
    int i= 0;
     
    while(rs.next()){
     
    an.add(i,new BiensVendus(rs.getInt("annee"),rs.getString("numero"),rs.getString("adresse"),rs.getInt("prix"),rs.getString("genre"),date,rs.getInt("idQuartier"),rs.getString("note")));
    i++;
     
    }
     
    } 
    catch(SQLException e){e.printStackTrace();}
    System.out.println("an");
     
    return an;
    }
    et voila l'exception
    org.postgresql.util.PSQLException: L'indice de la colonne est hors limite*: 1, nombre de colonnes*: 0.
    at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:52)
    at org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:117)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2120)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1241)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1227)
    at BD.DB.dateVente(DB.java:187)
    at ihm.Choix.actionPerformed(Choix.java:117)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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)
    voila merci

  5. #5
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut précision
    en fait la date se trouve a la 6ème colone dans ma base de donnée, je sais pas si c'est utile comme précision

  6. #6
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Citation Envoyé par moifistand Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    	at BD.DB.dateVente(DB.java:187)
    Y'a quoi a la ligne 187 du fichier DB.java ?

  7. #7
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut ligne 187
    select_date.setString(1,date);

  8. #8
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Citation Envoyé par moifistand Voir le message
    select_date.setString(1,date);
    A l'aveugle je dirai d'essayer :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    select_date.setString(0,date);

  9. #9
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    ben c'est ce que j'ai déja dans mon code, ça vient pas d'un souci de curseur ou je sais pas quoi? genre que je pointe pas sur la bonne colonne ou je sais pas

  10. #10
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    arf j'avais mal lu, je test

  11. #11
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Ouais je ma tromper... J'ai editer après coup...

    Essaye de mettre 0 au lieu de 1 dans

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    select_date.setString(1,date);

  12. #12
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Mouais... Ca a pas l'air d'etre ca d'après le JavaDoc...

  13. #13
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    marche pas, il me met exactement la meme exception sauf que au lieu de 1 il me met 0 pour l'indice hors limite
    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
     
    org.postgresql.util.PSQLException: L'indice de la colonne est hors limite*: 0, nombre de colonnes*: 0.
    at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:52)
    at org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:117)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2120)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1241)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1227)
    at BD.DB.dateVente(DB.java:187)
    at ihm.Choix.actionPerformed(Choix.java:117)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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)

  14. #14
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Remet 1 et pourrai-tu afficher la valeur de date juste avant l'appel au setString la ?

  15. #15
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    21.01.05
    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
     
    org.postgresql.util.PSQLException: L'indice de la colonne est hors limite*: 1, nombre de colonnes*: 0.
        at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:52)
        at org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:117)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2120)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1241)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1227)
        at BD.DB.dateVente(DB.java:189)
        at ihm.Choix.actionPerformed(Choix.java:117)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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)
    la valeur de date est bonne

  16. #16
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Hahahah j'ai trouvé !

    http://www.developpez.net/forums/sho...d.php?t=119656

    En fait, je me suis fait souvent avoir avec ça ! C'est le symbol ` qu'il faut utiliser et pas le ' dans la requete !!

  17. #17
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    21.01.05
    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
     
    org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying =` character varying
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
        at BD.DB.dateVente(DB.java:190)
        at ihm.Choix.actionPerformed(Choix.java:117)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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)
    apparement c'est pas ça, le bon point c'est qu'il varie dans l'exception lol

  18. #18
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Arrgh... Je crois que c'est parce que la date est mal formé

    Il faut un truc du genre : '1994-11-27'

    http://www.gcolpart.com/howto/postgresql.php4

  19. #19
    Candidat au Club
    Inscrit en
    Avril 2008
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 14
    Points : 2
    Points
    2
    Par défaut
    oui mais la c'est du String, du coup je fais une comparaison toute simple de chaine de caractère, c'est pas possible?

  20. #20
    Membre habitué
    Profil pro
    Devops
    Inscrit en
    Août 2006
    Messages
    107
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Devops

    Informations forums :
    Inscription : Août 2006
    Messages : 107
    Points : 139
    Points
    139
    Par défaut
    Citation Envoyé par moifistand Voir le message
    je fais une comparaison toute simple de chaine de caractère
    Gné ? Excuse mais c'est vendredi

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Réponses: 2
    Dernier message: 29/05/2007, 15h35
  2. Indice de liste hors limite
    Par pierrot67 dans le forum Bases de données
    Réponses: 2
    Dernier message: 14/02/2007, 11h42
  3. [débutant] erreur "indice de liste hors limites(1)"
    Par lidouka dans le forum Langage
    Réponses: 2
    Dernier message: 13/12/2005, 14h31
  4. Indice de liste hors limite !!! Report
    Par EssaiEncore dans le forum Langage
    Réponses: 1
    Dernier message: 29/11/2005, 10h00
  5. indice de grille hors limite....
    Par steph_1 dans le forum Langage
    Réponses: 12
    Dernier message: 02/08/2005, 11h18

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