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

Hibernate Java Discussion :

probleme return et INFO: Not binding factory to JNDI, no JNDI name configured


Sujet :

Hibernate Java

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    154
    Détails du profil
    Informations personnelles :
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Février 2008
    Messages : 154
    Par défaut probleme return et INFO: Not binding factory to JNDI, no JNDI name configured
    Bonjour,
    je debute en java;
    je veux recuperer des informations en base et les retourner dans un objet afin qu'il soit utiliser ailleurs;
    mais lorsque j'appelle ma fonction, elle ne retourne aucun resultat et pourtant quand je fais un system.out.println, je vois bien les resultats s'afficher

    voici mon 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
     
    public class testcomp {
    	public String  afficherBoutiques () throws HibernateException 
    	{
     
    		String  iti = "Bonjour";
     		Session session = HibernateUtil.currentSession();
     
    		List list = session.find("from Boutiques");	
    		Iterator it = list.iterator();
    			while(it.hasNext())
    			{
    				Boutiques Boutik = (Boutiques)it.next();
    				//System.out.println(Boutik.getURLWSBoutik());
    				   iti=  Boutik.getURLWSBoutik();
     
    			}
     
     
     		return iti;
     
     
    }
    j'appelle ma fonction:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    public class Tests
    {
    	public static void main(String[] args) throws HibernateException 
    	{
     
    	testcomp monTest = new testcomp();
    		monTest.afficherBoutiques();
            }
    }
    quand je compile,la console me renvoie ceci:
    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
    50
    51
    52
    53
    54
    55
    56
    57
     
    18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration addResource
    INFO: Mapping resource: Boutiques.hbm
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Binder bindRootClass
    INFO: Mapping class: com.yohan.hibernate.Boutiques -> boutiques
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-many association mappings
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-one association property references
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing foreign key constraints
    18 avr. 2010 06:16:13 net.sf.hibernate.dialect.Dialect <init>
    INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Maximim outer join fetch depth: 2
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use outer join fetching: true
    18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/bdcomparateur
    18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=root, password=}
    18 avr. 2010 06:16:13 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
    INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
    18 avr. 2010 06:16:13 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use scrollable result sets: true
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use JDBC3 getGeneratedKeys(): true
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: false
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
    18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration configureCaches
    INFO: instantiating and configuring caches
    18 avr. 2010 06:16:14 net.sf.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    18 avr. 2010 06:16:14 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    mon fichier hibernate.cfg.xml:
    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
     
    <hibernate-configuration>
        <session-factory >
     
    		<!-- local connection properties -->
    		<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/bdcomparateur</property>
    		<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    		<property name="hibernate.connection.username">root</property>
    		<property name="hibernate.connection.password"></property>
    		<!-- property name="hibernate.connection.pool_size"></property -->
     
    		<!-- dialect for MySQL -->
            <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
     
            <property name="hibernate.show_sql">false</property>
            <property name="hibernate.use_outer_join">true</property>
     
          <!--  <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
            <property name="jta.UserTransaction">java:comp/UserTransaction</property> -->
     
            <property name="hibernate.transaction.factory_class">
    			net.sf.hibernate.transaction.JDBCTransactionFactory
     
    		</property>
    		<mapping resource="Boutiques.hbm" />
     
     
        </session-factory>
    </hibernate-configuration>
    avec aucun resultat.

    pouvez vous m'aider svp? merci.

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

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    en même temps, ton code ne fait rien, donc t'aurais du mal à voir grand chose. Quand au "INFO: Not binding factory to JNDI, no JNDI name configured" tu peux l'ignorer. Je noterais quand même les erreurs suivantes.

    1) afficher boutique n'affiche rien, contrairement à ce que son nom indique
    2) afficher boutique parcours une collection et retourne uniquement le dernier élément trouvé (j'ignore si c'est volontaire)
    3) dans ton main tu appelle afficher boutique mais tu ne fait rien de la valeur de retour

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    154
    Détails du profil
    Informations personnelles :
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Février 2008
    Messages : 154
    Par défaut
    bonjour,
    alors comment je fais alors?
    je voulais tester ma fonction pour vpir si le return fonctionne.
    comment faire svp pour que mon return affiche quelquechose?

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

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    le return, par définition, il retourne, il affiche pas .


    Si tu veux afficher la valeur de retour, ben tu utilise un System.out.println .....

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    154
    Détails du profil
    Informations personnelles :
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Février 2008
    Messages : 154
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    le return, par définition, il retourne, il affiche pas .


    Si tu veux afficher la valeur de retour, ben tu utilise un System.out.println .....
    ok je comprends mieux;
    le System.out.println marche tres bien,il affiche bien les resultats;
    par contre je voudrais tester le return;
    comment savoir que ma fonction retourne effectivement quelquechose?

    autre preoccupation: quel est le type approprié pour ma fonction vu que je compte utilisé l'objet retourne dans un autre traitement? list ,iterator ou string?

    merci

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

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    pour tester la valeur de retour, ben tu l'affiche


    pour le type de la valeur de retour, ca dépend ce que dois faire ta méthode.

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    154
    Détails du profil
    Informations personnelles :
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Février 2008
    Messages : 154
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public class testcomp {
    	public String  afficherBoutiques (String NomP) throws HibernateException 
    	{
     
    		String  iti = " ";
     		Session session = HibernateUtil.currentSession();
     
    		List list = session.find("from Boutiques");	
    		Iterator it = list.iterator();
    			while(it.hasNext())
    			{
    				Boutiques Boutik = (Boutiques) it.next();
    Citation Envoyé par tchize_ Voir le message
    Je noterais quand même les erreurs suivantes.
    2) afficher boutique parcours une collection et retourne uniquement le dernier élément trouvé (j'ignore si c'est volontaire)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    				iti+=  Boutik.getURLWSBoutik()+NomP;
     
    			}
    Citation Envoyé par tchize_ Voir le message
    pour tester la valeur de retour, ben tu l'affiche


    pour le type de la valeur de retour, ca dépend ce que dois faire ta méthode.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
     		system.out.println (iti);
     		return iti;
     
     
    }
    le system.out.println affche effectivement tous mes resultats.
    merci.

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

Discussions similaires

  1. Réponses: 0
    Dernier message: 24/03/2012, 02h19
  2. Could not bind to address 0.0.0.0:80 ...
    Par killy-kun dans le forum Apache
    Réponses: 3
    Dernier message: 04/12/2008, 12h48
  3. [3.2.3]Erreur Could not bind factory to JNDI
    Par lazarel dans le forum Hibernate
    Réponses: 7
    Dernier message: 15/07/2008, 12h37
  4. Réponses: 2
    Dernier message: 22/05/2007, 03h45
  5. probleme return confirm avec firefox
    Par druglord dans le forum Général JavaScript
    Réponses: 12
    Dernier message: 24/08/2005, 10h14

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