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 eclipse mysql , erreur: The user must supply a JDBC connection


Sujet :

Hibernate Java

  1. #1
    Candidat au Club
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 4
    Points
    4
    Par défaut hibernate eclipse mysql , erreur: The user must supply a JDBC connection
    Bonjour,

    J'utilise eclipse 3.5 avec MySQL 5.1 et hibernate 2.1.2 j'ai créé une classe Personnes et j'ai les fichiers de configuration suivants:

    le fichier: Personnes.hbm.xml

    <?xml version="1.0"?><!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
    <class name="hiber.pers.Personnes" table=" personnes">
    <id name="idPersonne" type="int" column="idpersonne">
    <generator class="native"/>
    </id>
    <property name="nomPersonne" type="string" not-null="true" />
    <property name="prenomPersonne" type="string" not-null="true" />
    <property name="datenaissPersonne" type="date">
    <meta attribute="field-description">date de naissance</meta>
    </property>
    </class>
    </hibernate-mapping>

    et le fichier :hibernate.cfg.xml


    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost/personnesd</property>
    <property name="connection.username">root</property>
    <property name="connection.password">root</property>

    <property name="show_sql">true</property>
    <property name="hibernate.use_outer_join">true</property>
    <property name="hibernate.transaction.factory_class">
    net.sf.hibernate.transaction.JDBCTransactionFactory
    </property>
    <property name="jta.UserTransaction">
    java:comp/UserTransaction
    </property>

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

    j'ai l'erreur suivant :

    log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection
    at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:32)
    at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
    at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264)
    at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244)
    at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
    at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
    at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2195)
    at hiber.pers.TestHibernate1.main(TestHibernate1.java:17)


    Sachant que j'ai testé ma connexion JDBC sans hibernate et ça marche bien .

    Merci d'avance pour votre aide .

  2. #2
    Membre expert Avatar de KiLVaiDeN
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    2 851
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 2 851
    Points : 3 481
    Points
    3 481
    Par défaut
    Bonjour,

    Peut-être qu'en précisant le port dans l'url de connection JDBC ça marcherait mieux ?
    K

  3. #3
    Candidat au Club
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 4
    Points
    4
    Par défaut
    j'ai le même prob même si je précise le port 3306 comme si j'a fai rien !

  4. #4
    Membre expert Avatar de KiLVaiDeN
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    2 851
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 2 851
    Points : 3 481
    Points
    3 481
    Par défaut
    Peut-être que ton fichier hibernate.cfg.xml n'est pas chargé. Comment as-tu déclaré qu'il devait se charger ? Utilises-tu Spring ?
    K

  5. #5
    Candidat au Club
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 4
    Points
    4
    Par défaut
    Bonjour,

    j'utilise pas Spring je fais une application "standalone"

    pour charger les fichiers de configuration normalement les instructions

    suivantes sont suffits :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     Configuration config = new Configuration();
        config.addClass(Personnes.class);

Discussions similaires

  1. Erreur "The user must supply a JDBC connection"
    Par kanebody dans le forum JPA
    Réponses: 2
    Dernier message: 09/03/2013, 12h55
  2. user must supply a jdbc connection
    Par touane dans le forum Hibernate
    Réponses: 1
    Dernier message: 12/02/2010, 23h51
  3. The user must supply a JDBC connection
    Par mithrendil dans le forum Hibernate
    Réponses: 5
    Dernier message: 26/04/2009, 12h56
  4. erreur: The user must supply a JDBC connection
    Par khallouk_soft dans le forum Hibernate
    Réponses: 4
    Dernier message: 02/12/2006, 13h53
  5. [hibernate][mysql] erreurs
    Par nikalkal dans le forum Hibernate
    Réponses: 1
    Dernier message: 25/04/2006, 17h40

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