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 :

connexion a informix par hibernate


Sujet :

Hibernate Java

  1. #1
    Candidat au Club
    Inscrit en
    Mars 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 7
    Points : 2
    Points
    2
    Par défaut connexion a informix par hibernate
    bonjour,
    j'essai d'executer un projet en hibernate, mais je reçois l'erreur suivante.
    "Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:307)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:109)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:134)
    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1167)
    at src.actions.addFournisseur(actions.java:36)
    at src.actions.main(actions.java:29)
    Caused by: java.sql.SQLException: Transactions not supported
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:349)
    at com.informix.jdbc.IfxSqliConnect.setAutoCommit(IfxSqliConnect.java:1627)
    at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:112)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:304)"

    est ce que qlq'un peut me préciser la cause de cette erreur.
    merci bien

  2. #2
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    il semblerait que tu ne parviens pas a te connecter a ta base de donnees Informix, et je dirais que le pb ne vient pas forcement d'Informix.

    Essaye de realiser une connection JDBC sans Hibernate.

  3. #3
    Candidat au Club
    Inscrit en
    Mars 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 7
    Points : 2
    Points
    2
    Par défaut

    en fait j'avais oublier de dire que je travail sous RSA, donc faut il configurer qlqchose dans ce logicil, ou il suffit d'ajouter les libs

  4. #4
    Candidat au Club
    Inscrit en
    Mars 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 7
    Points : 2
    Points
    2
    Par défaut
    merci bcp;
    j'ai réalisé la connexion JDBC sans hibernate et ça marche très bien.
    alors à ton avis c koi le prob?

  5. #5
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Fais voir ton fichier de config Hibernate.
    Et ton fichier de mapping

  6. #6
    Candidat au Club
    Inscrit en
    Mars 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 7
    Points : 2
    Points
    2
    Par défaut
    le fichier hibenate:
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <!-- Database connection settings -->
    <property name="connection.driver_class">com.informix.jdbc.IfxDriver</property>
    <property name="connection.url">jdbc:informix-sqli://10.6.45.4:1175/base_serie:INFORMIXSERVER=dette_dev</property>
    <property name="connection.username">stage1</property>
    <property name="connection.password">stage1</property>
    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>
    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.InformixDialect</property>
    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>
    <!-- Disable the second-level cache -->
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>
    <!-- Drop and re-create the database schema on startup -->
    <property name="hbm2ddl.auto">create</property>
    <mapping resource="src/devise.hbm.xml"/>
    <mapping resource="src/domaine.hbm.xml"/>
    <mapping resource="src/fournisseur.hbm.xml"/>
    <mapping resource="src/frequence.hbm.xml"/>
    <mapping resource="src/methodeObservation.hbm.xml"/>
    <mapping resource="src/valeur.hbm.xml"/>
    <mapping resource="src/interdire.hbm.xml"/>
    <mapping resource="src/qualite.hbm.xml"/>
    <mapping resource="src/profil.hbm.xml"/>
    <mapping resource="src/utilisateur.hbm.xml"/>
    <mapping resource="src/serie.hbm.xml"/>
    </session-factory>
    </hibernate-configuration>


    j'ai plusieurs fichiers de mapping et voila un exemple:

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

    <hibernate-mapping package="src.classMapping">
    <class name="utilisateur" table="UTILISATEUR">
    <id name="codeUtilisateur" column="CODE_UTILISATEUR">
    <generator class="assigned"/>
    </id>
    <property name="login" column="LOGIN"/>
    <property name="password" column="PASSWORD"/>

    <set name="utilisateurProfil" inverse="true" table="PROFIL_UTILISATEUR">
    <key column="CODE_UTILISATEUR"/>
    <many-to-many column="CODE_PROFIL" class="profil"/>
    </set>
    </class>

    </hibernate-mapping>



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

    <hibernate-mapping package="src.classMapping">
    <class name="profil" table="PROFIL">
    <id name="codeProfil" column="CODE_PROFIL">
    <generator class="native"/>
    </id>
    <property name="libelleProfil" column="LIBELLE_PROFIL"/>

    <set name="utilisateurProfil" inverse="true" table="PROFIL_UTILISATEUR">
    <key column="CODE_PROFIL" not-null="true"/>
    <many-to-many column="CODE_UTILISATEUR" class="utilisateur"/>
    </set>
    </class>

    </hibernate-mapping>

  7. #7
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Et ton code Java aussi s'il te plait (la ou tu ouvre ta connexion).

    Utilise la balise code c'est plus lisible aussi (avec le symbole #)

  8. #8
    Candidat au Club
    Inscrit en
    Mars 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 7
    Points : 2
    Points
    2
    Par défaut
    voici le main

    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;

    import src.action.*;
    import src.classMapping.*;
    import src.util.HibernateUtil;
    import java.sql.*;
    /*
    * Créé le 6 avr. 2007
    *
    * TODO Pour changer le modèle de ce fichier généré, allez à :
    * Fenêtre - Préférences - Java - Style de code - Modèles de code
    */

    /**
    * @author Administrateur
    *
    * TODO Pour changer le modèle de ce commentaire de type généré, allez à :
    * Fenêtre - Préférences - Java - Style de code - Modèles de code
    */
    public class actions {

    public static void main(String[] args) {

    org.apache.log4j.BasicConfigurator.configure();
    addFournisseur("four 2","MF","rabat","236578");
    HibernateUtil.getSessionFactory().close();
    }


    private static void addFournisseur(String code, String name,String adresse,String tel) {

    //ouverture de session
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    Session session =sessionFactory.openSession();
    session.beginTransaction();


    fournisseur four = new fournisseur();
    four.setCodeFournisseur(code);
    four.setLibelleFournisseur(name);
    four.setAdresseFournisseur(adresse);
    four.setTelFournisseur(tel);
    session.save(four);
    System.out.println("Done");
    }
    }



    et voici la classe util que j'appelle:



    import org.hibernate.*;
    import org.hibernate.cfg.*;

    public class HibernateUtil {

    private static final SessionFactory sessionFactory;

    static {
    try {
    // Create the SessionFactory from hibernate.cfg.xml
    sessionFactory = new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) {
    // Make sure you log the exception, as it might be swallowed
    System.err.println("Initial SessionFactory creation failed." + ex);
    throw new ExceptionInInitializerError(ex);
    }
    }
    public static final ThreadLocal session = new ThreadLocal();
    public static SessionFactory getSessionFactory() {
    return sessionFactory;
    }

    }

  9. #9
    Candidat au Club
    Inscrit en
    Mars 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 7
    Points : 2
    Points
    2
    Par défaut
    en fait j'ai trouvé la source du problème:
    c ke j'avais importer les bibliotheques hibernate 2 et 3 ce ki me creait u conflit, faute de copier/coller

Discussions similaires

  1. [OWB] Connexion vers Informix : ODBC, Trasparent Gateway ?
    Par marchand_de_sable dans le forum Oracle
    Réponses: 1
    Dernier message: 22/11/2006, 14h47
  2. Connexion Oracle-PHP par ODBC
    Par lcf84 dans le forum Oracle
    Réponses: 2
    Dernier message: 12/10/2006, 13h32
  3. Connexion entre Informix et Oracle
    Par Paikan92 dans le forum Informix
    Réponses: 1
    Dernier message: 02/09/2006, 12h25
  4. Connexion entre Informix et Oracle
    Par Paikan92 dans le forum Oracle
    Réponses: 4
    Dernier message: 15/06/2006, 15h19
  5. Réponses: 5
    Dernier message: 17/05/2006, 09h19

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