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

 Java Discussion :

Collecter ce qui existe dans la base de données


Sujet :

Java

  1. #1
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut Collecter ce qui existe dans la base de données
    bonjour,

    J'ai un code qui collecte ce qu'il y a dans la base de données et qui ne retourne que des null
    Je vous met le 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
    		String cmd = "SELECT * FROM T_PREDICAT WHERE nuIdDoc = " + iIdDoc;
    		ResultSet resultset = InterbaseManager.ExecuteSelectRequest(cmd);
    		while( resultset.next())
    		{
    			predicatNormalized = new PropositionNormalized();
    			nuIdPredicat = resultset.getInt( 1);
    			predicatNormalized.TypeProposition = resultset.getInt( 2);;
    			predicatNormalized.indice = resultset.getInt( 3);;
    			predicatNormalized.Occurence = resultset.getInt( 4);
    			predicatNormalized.iEnumerated = resultset.getInt( 5);
    			predicatNormalized.iPOS = resultset.getInt( 6);
    			predicatNormalized.iPers = resultset.getInt( 7);
    			predicatNormalized.iNbr = resultset.getInt( 8);
    			predicatNormalized.TypeData = resultset.getInt( 9);
    			predicatNormalized.ListParagraph = resultset.getString( 12);
    			predicatNormalized.Univers = new Univers();
    			predicatNormalized.Univers.wsName = resultset.getString( 13);
    			predicatNormalized.Declencheur = resultset.getString( 14);
    			predicatNormalized.Configuration = resultset.getString( 15);
    			predicatNormalized.Identifier = resultset.getString( 18);
    			predicatNormalized.Sujet = resultset.getString( 19);
    			predicatNormalized.Verb = resultset.getString( 20);
    			predicatNormalized.Complement = resultset.getString( 21);
    			predicatNormalized.Precision = resultset.getString( 22);
    			predicatNormalized.Frequence = resultset.getString( 23);
    			predicatNormalized.Comment = resultset.getString( 24);
    			predicatNormalized.wskeyValue = resultset.getString( 25);
    			predicatNormalized.operande = resultset.getString( 26);
    			predicatNormalized.min = resultset.getInt( 27);
    			predicatNormalized.max = resultset.getInt( 28);
    			predicatNormalized.type = resultset.getInt( 29);
    			predicatNormalized.Univers.idParagraph = resultset.getInt( 33);;
    			predicatNormalized.iIdDoc = resultset.getInt( 35);
    	                listOfPredicat.add( predicatNormalized);
    		}
    		pList.add( listOfPredicat);
    alors que la base de données contient des champs significatifs
    Qui me donnera une piste sera

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Comment tu sais que ça ne retourne que des null? D'autant que getInt ne peut pas retourner null... A quoi ressemble PropositionNormalized? A quoi ressemble ta table?

  3. #3
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut je te donne la table
    que je collecte par ssmsNom : ssms.gif
Affichages : 54
Taille : 263,1 Ko
    pour le résultat je vérifie les donnée a la sortie de la méthode, ce n'est peut être pas des null mais des valeurs O ou ""

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    tu peux rajouter ceci dans ton while et nous dire ce que ça affiche?


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    for (int i = 1; i<=resultSet.getMetaData().geColumnCount(); i++){
       System.out.println("column "+i+" ( "+resultSet.getMetaData().geColumnName(i)+") = "+resultSet.getObject(i)+" :"+resultSet.getMetaData().geColumnClassName(i));
    }
    Aussi, en général, il est préférable d'utiliser les méthodes getXXX(String) plutot que getXXX(int) quand on fait un select *, car on ne peut pas vraiment être sur de l'ordre des colonnes retournées.

  5. #5
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut j'ai injecté ton code dans le mien: je te donne le résultat
    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
    column 1 ( nuIdPredicat) = 1 :java.math.BigDecimal
    column 2 ( TypeProposition) = 0 :java.lang.Short
    column 3 ( indice) = 1 :java.lang.Short
    column 4 ( Occurence) = 0 :java.lang.Short
    column 5 ( iEnumerated) = 3 :java.lang.Short
    column 6 ( iPOS) = 0 :java.lang.Short
    column 7 ( iPers) = 0 :java.lang.Short
    column 8 ( iNbr) = 0 :java.lang.Short
    column 9 ( TypeData) = 1 :java.lang.Short
    column 10 ( ValWords) = null :java.lang.Short
    column 11 ( ListParagraph) = '1 ' :java.lang.String
    column 12 ( wsName) = ''Filling'' :java.lang.String
    column 13 ( Declencheur) = '' :java.lang.String
    column 14 ( Configuration) = null :java.lang.String
    column 15 ( Identifier) = 'Ignition Subsystem ' :java.lang.String
    column 16 ( Sujet) = 'The Ignition Subsystem Ignition Key or PASE' :java.lang.String
    column 17 ( Verb) = 'has ' :java.lang.String
    column 18 ( Complement) = '3 states , either OFF or +APC or +DEM ' :java.lang.String
    column 19 ( wsPrecision) = null :java.lang.String
    column 20 ( Frequence) = null :java.lang.String
    column 21 ( Comment) = 'The Ignition Subsystem Ignition Key or PASE has 3 states , either OFF or +APC or +DEM ' :java.lang.String
    column 22 ( wskeyValue) = null :java.lang.String
    column 23 ( operande) = null :java.lang.String
    column 24 ( iValues) = null :java.lang.Short
    column 25 ( imin) = 0 :java.lang.Short
    column 26 ( imax) = 0 :java.lang.Short
    column 27 ( itype) = 3 :java.lang.Short
    column 28 ( bIsEnumerated) = null :java.lang.String
    column 29 ( bAllocated) = null :java.lang.String
    column 30 ( bStatus) = null :java.lang.String
    column 31 ( idParagraph) = 1 :java.lang.Short
    column 32 ( plistLink) = null :java.lang.Integer
    column 33 ( pColors) = null :java.lang.Integer
    column 34 ( pWord) = null :java.lang.Integer
    column 35 ( nuIdDoc) = 1 :java.lang.Short
    Je modifie mon code en fonction des résultats et je reviens

  6. #6
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    comme tu le peux le voir aux nom des colonnes, ce que tu lit par index ne correspond pas aux colonnes que tu vise.Et pour certains, les types ne sont probablement pas bons. Je te met ton code annoté pour que tu vois le problème.
    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
     
    			nuIdPredicat = resultset.getInt( 1);  // column 1 ( nuIdPredicat) = 1 :java.math.BigDecimal
                                                            // int est probablement trop limité pour contenir les valeurs possibles. de l'identifier
    			predicatNormalized.TypeProposition = resultset.getInt( 2);; // column 2 ( TypeProposition) = 0 :java.lang.Short
    			predicatNormalized.indice = resultset.getInt( 3);; //column 3 ( indice) = 1 :java.lang.Short
    			predicatNormalized.Occurence = resultset.getInt( 4); //column 4 ( Occurence) = 0 :java.lang.Short
    			predicatNormalized.iEnumerated = resultset.getInt( 5); //column 5 ( iEnumerated) = 3 :java.lang.Short
    			predicatNormalized.iPOS = resultset.getInt( 6); //column 6 ( iPOS) = 0 :java.lang.Short
    			predicatNormalized.iPers = resultset.getInt( 7); //column 7 ( iPers) = 0 :java.lang.Short
    			predicatNormalized.iNbr = resultset.getInt( 8); //column 8 ( iNbr) = 0 :java.lang.Short
    			predicatNormalized.TypeData = resultset.getInt( 9); //column 9 ( TypeData) = 1 :java.lang.Short
    // C'est ici que ça commence à merder
    			predicatNormalized.ListParagraph = resultset.getString( 12); //column 12 ( wsName) = ''Filling'' :java.lang.String
    			predicatNormalized.Univers = new Univers(); 
    			predicatNormalized.Univers.wsName = resultset.getString( 13);//column 13 ( Declencheur) = '' :java.lang.String
    			predicatNormalized.Declencheur = resultset.getString( 14); //column 14 ( Configuration) = null :java.lang.String
    			predicatNormalized.Configuration = resultset.getString( 15); /column 15 ( Identifier) = 'Ignition Subsystem ' :java.lang.String
    			predicatNormalized.Identifier = resultset.getString( 18); //column 18 ( Complement) = '3 states , either OFF or +APC or +DEM ' :java.lang.String
    			predicatNormalized.Sujet = resultset.getString( 19); //column 19 ( wsPrecision) = null :java.lang.String
    			predicatNormalized.Verb = resultset.getString( 20); //column 20 ( Frequence) = null :java.lang.String
    			predicatNormalized.Complement = resultset.getString( 21); //column 21 ( Comment) = 'The Ignition Subsystem Ignition Key or PASE has 3 states , either OFF or +APC or +DEM ' :java.lang.String
    			predicatNormalized.Precision = resultset.getString( 22); //column 22 ( wskeyValue) = null :java.lang.String
    			predicatNormalized.Frequence = resultset.getString( 23); //column 23 ( operande) = null :java.lang.String
     
    //Etc, etc

  7. #7
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut le code mis à jour et le problème rémanant
    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
    		ArrayList<ArrayList> pList = new ArrayList<ArrayList>();
    		Short nuIdPredicat;
    		ArrayList<PropositionNormalized> listOfPredicat;
    		ArrayList<PropositionNormalized> listOfPrecondition;
    		ArrayList<QualificateurNormalized> listOfQualificateur;
    		listOfPredicat = new ArrayList();
    		listOfPrecondition = new ArrayList();
    		listOfQualificateur = new ArrayList();
    		String cmd = "SELECT * FROM T_PREDICAT WHERE nuIdDoc = " + iIdDoc;
    		ResultSet resultset = InterbaseManager.ExecuteSelectRequest(cmd);
    		while( resultset.next())
    		{
    			predicatNormalized = new PropositionNormalized();
    			nuIdPredicat = resultset.getShort( 1);
    			Short temp = resultset.getShort( 2);
    			predicatNormalized.TypeProposition = (int)temp;
    			temp = resultset.getShort( 3);
    			predicatNormalized.indice = (int)temp;
    			predicatNormalized.Occurence = (int)resultset.getShort( 4);
    			predicatNormalized.iEnumerated = (int)resultset.getShort( 5);
    			predicatNormalized.iPOS = (int)resultset.getShort( 6);
    			predicatNormalized.iPers = (int)resultset.getShort( 7);
    			predicatNormalized.iNbr = (int)resultset.getShort( 8);
    			predicatNormalized.TypeData = (int)resultset.getShort( 9);
    			predicatNormalized.ListParagraph = resultset.getString( 11);
    			predicatNormalized.Univers = new Univers();
    			predicatNormalized.Univers.wsName = resultset.getString( 12);
    			predicatNormalized.Declencheur = resultset.getString( 13);
    			predicatNormalized.Configuration = resultset.getString( 14);
    			predicatNormalized.Identifier = resultset.getString( 15);
    			predicatNormalized.Sujet = resultset.getString( 16);
    			predicatNormalized.Verb = resultset.getString( 17);
    			predicatNormalized.Complement = resultset.getString( 18);
    			predicatNormalized.Precision = resultset.getString( 19);
    			predicatNormalized.Frequence = resultset.getString( 20);
    			predicatNormalized.Comment = resultset.getString( 21);
    			predicatNormalized.wskeyValue = resultset.getString( 22);
    			predicatNormalized.operande = resultset.getString( 23);
    			predicatNormalized.min = (int)resultset.getShort( 25);
    			predicatNormalized.max = (int)resultset.getShort( 26);
    			predicatNormalized.type = (int)resultset.getShort( 27);
    			predicatNormalized.Univers.idParagraph = (int)resultset.getShort( 33);;
    			predicatNormalized.iIdDoc = (int)resultset.getShort( 35);
    	                listOfPredicat.add( predicatNormalized);
    		}
    dans ce code les variable temporaires sont à jour mais prédicatNormalized n'est pas 0 jour

  8. #8
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    qu'est-ce que tu entends par "pas à jour". Comme on a vu sur l'extrait les données sont bien présentes dans le resultset. Donc qu'est-ce que tu as dedans, qu'est-ce que tu aurais du avoir dedans, et quel code tu utilise pour l'afficher?

  9. #9
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut je te met la déclaration de propositionNormalized
    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
    package com.all4tec.matelo.linguistique.wizards;
     
    import java.util.ArrayList;
     
    import com.all4tec.matelo.datamodel.diagram.IMacroState;
     
    public class PropositionNormalized
    {
    		int     TypeProposition;
            int		indice;
            int		Occurence;
    		int		iEnumerated;
    		int     iPOS;
    		int     iPers;
    		int     iNbr;
    		int 	TypeData;
    		int		min;
    		int		max;
    		int		type;
    		boolean	bIsEnumerated;
            boolean	bAllocated;
            boolean	bStatus;
            IMacroState state;
            String  ValWords;
    		String  ListParagraph;
            Univers Univers;
            String  Declencheur;
            String  Configuration;
            String  Identifier;
            String  Sujet;
            String  Verb;
            String  Complement;
    		String  Precision;
            String  Frequence;
            String  Comment;
            String  wskeyValue;
            String  operande;
            ArrayList<QualificateurLink> pListLink;
    		ArrayList<AnalysedWord> pColors;
            ArrayList<AnalysedWord> pWord;
            int iIdDoc;
    }
    pour la réponse je vois sous débogueur que les variables intermédiaires sont mises a jour et que la proposition n'est pas mis a jour
    en fait quand j'utilise le System.out.println ça semble marcher. je continue et je reviens sur le résultat

  10. #10
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Ben si ton deboggueur te dit que les données sont bien dedans, c'est qu'elles sont dedans, donc je ne vois pas d'ou tu trouve qu'elles n'y sont pas :/ Bref, je comprend plus rien à c'est quoi ton problème.

  11. #11
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut je crois que ça marche
    sous déboguer je ne voyais rien, avec les printnl ça semble marcher.

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 14/12/2012, 12h42
  2. Réponses: 1
    Dernier message: 26/03/2012, 13h33
  3. [MySQL] Vérification de l'existence dans la base de données
    Par gadalla dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 28/05/2008, 09h54
  4. Réponses: 1
    Dernier message: 23/10/2005, 00h55
  5. Réponses: 2
    Dernier message: 20/05/2005, 10h18

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