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 :

Hibernate : problème de connexion


Sujet :

Hibernate Java

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut Hibernate : problème de connexion
    Bonjour,

    Voila je débute avec hibernate et j'ai le soucis suivant :

    Voici aussi mon fichier de conf hibernate

    <?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/test</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">admin</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>

    <mapping resource="Caisse.hbm.xml" />
    </session-factory>
    </hibernate-configuration>


    Voici ma fichier Caisse.hbm.xml :

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

    <hibernate-mapping>
    <class name="com.minosis.hibernate.Caisse" table="caisse">
    <property
    column="montantC"
    length="22"
    name="MontantC"
    not-null="true"
    type="java.lang.Double"
    />
    <property
    column="Statut"
    length="20"
    name="Statut"
    not-null="true"
    type="string"
    />
    <property
    column="Id_Pers"
    name="IdPers"
    not-null="true"
    type="string"
    />
    <property
    column="montantO"
    length="22"
    name="MontantO"
    not-null="true"
    type="java.lang.Double"
    />
    </class>
    </hibernate-mapping>

    Et voici les erreurs affichées :

    24-janv.-2008 11:52:06 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    24-janv.-2008 11:52:06 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    24-janv.-2008 11:52:06 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    24-janv.-2008 11:52:06 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    24-janv.-2008 11:52:06 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    24-janv.-2008 11:52:06 net.sf.hibernate.cfg.Configuration addResource
    INFO: Mapping resource: Caisse.hbm.xml
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at tools.Welcome.build(Welcome.java:57)
    at tools.Welcome.<init>(Welcome.java:41)
    at PointOfSale.main(PointOfSale.java:29)
    Caused by: java.lang.RuntimeException: Exception building SessionFactory: Resource: Caisse.hbm.xml not found
    at com.minosis.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:19)
    ... 3 more
    Caused by: net.sf.hibernate.MappingException: Resource: Caisse.hbm.xml not found
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:334)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:883)
    at com.minosis.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:16)
    ... 3 more


    J'ai deja essayé de mettre le nom du package dans le hibernate mapping mais cela ne fonctionne pas non plus

    Si vous avez une idée, merci d'avance

  2. #2
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    premièrement je te conseille d'utiliser hibernate3, autant commencer par la version actuelle

    ensuite c'est vraisemblablement un problème de chemin

    si tu utilises
    <mapping resource="Caisse.hbm.xml" />
    alors ton fichier doit se trouver à la racine de ton arborescence (normalement avec ton hibernate.cfg.xml)

    si tu les as mis à l'intérieur d'un package, précise le chemin
    <mapping resource="monPackage/Caisse.hbm.xml" />

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut
    Merci pour la réponse,

    Si c'est ca que tu me conseilles de faire, je l avais deja essayé avant mais la meme erreur apparait encore

    <mapping resource="com/minosis/hibernate/Caisse.hbm.xml" />

    Je pense aussi que c'est un probleme de hemin, mais je ne vois pas ou est le probleme

    m

  4. #4
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    tu peux décrire ton arborescence de fichiers ?

    et travailles tu avec un EDI ?

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut
    oui je travaille ave Eclipse

    Arorescene de fichier :

    Dans src

    Main
    Caisse.htm
    hibernate.cfg.xml
    +com.minosis.hibernate
    Caisse.java
    hibernateUtil.java
    +com.minosis.hibernate.base
    +com.minosis.hibernate.dao

  6. #6
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    je vois la un caisse.htm, c'est une faute de frappe ou le nom de ton fichier ?

    les + ce sont des noms de packages (donc des dossiers) ?

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut
    Citation Envoyé par Gardyen Voir le message
    je vois la un caisse.htm, c'est une faute de frappe ou le nom de ton fichier ?
    c'est bien le nom de mon fichier

    Citation Envoyé par Gardyen Voir le message
    les + ce sont des noms de packages (donc des dossiers) ?
    oui les + sont des packages (caisse.java et HibernateUtil.java sont dans le package com.minosis.hibernate)

  8. #8
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut
    Gardyen, pas d'idées?

  9. #9
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    ton fichier Caisse.hbm.xml n'apparaît pas dans ton arborescence, oubli ?

  10. #10
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut
    non mais lorsque je crée les différents package hibernate avec Eclipse, il ne me crée pas de fichier hbm.xml, dois-je les créér moi-meme? ou je peux m en passer et mapper sur le hbm?

  11. #11
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    tu as ta réponse, comment veux-tu qu'hibernate trouve un fichier Caisse.hbm.xml quand tu as un fichier Caisse.hbm ?

    utilise ce nom dans le mapping resource

  12. #12
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2008
    Messages : 37
    Points : 14
    Points
    14
    Par défaut
    oui ok merci, d autres erreurs apparaissent,mais je vais regarder à ca!

    merci

Discussions similaires

  1. problème de connexion hibernate sous iReport
    Par moha_alnif dans le forum iReport
    Réponses: 0
    Dernier message: 21/04/2009, 15h10
  2. Hibernate - Problème de connexion à la base
    Par fairyyoy dans le forum Eclipse Java
    Réponses: 0
    Dernier message: 04/11/2008, 04h43
  3. Réponses: 1
    Dernier message: 12/02/2008, 17h25
  4. Eclipse-hibernate-Problème de connexion
    Par matech dans le forum Hibernate
    Réponses: 9
    Dernier message: 14/08/2007, 11h36
  5. Réponses: 1
    Dernier message: 14/02/2007, 10h48

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