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 :

PB Passage d'une BD Oracle à PostGRE SQL


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 4
    Par défaut PB Passage d'une BD Oracle à PostGRE SQL
    Bonjour je dois passer d'une base de donnée Oracle à une BD POSTGRES, la persistance des données est gérée par Hibernate. Actuellement, avec la BD oracle tout marche bien j'arrive à insérer des données et voir les données. J'ai recrée la même base en postgres, mais ca marche pas. J'ai oublié de préciser que j'accede au database depuis un serveur tomcat su lequel je déployer des web services.

    Voici le fichier database-beans.xml d'Oracle
    *************************************************************************
    Code xml : 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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     
            <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
                    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
                    <property name="jdbcUrl" value="jdbc:oracle:thin:@//172.20.3.4:1521/b2idb_taf"/>
                    <property name="user" value="scratch" />
                    <property name="password" value="bgan31" />
                    <property name="maxPoolSize" value="5" />
                    <property name="minPoolSize" value="1" />
                    <property name="maxIdleTime" value="5000" />
            </bean>
     
            <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                    <property name="dataSource" ref="dataSource" />
                    <property name="jpaVendorAdapter">
                            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                                    <property name="generateDdl" value="false" />
                                    <property name="databasePlatform" value="org.hibernate.dialect.Oracle9Dialect" />
                            </bean>
                    </property>
            </bean>
     
            <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
     
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
     
        <tx:annotation-driven />
     
        <bean id="carteDaoJpaImpl" class="com.viveris.vizada.soapServices.model.carte.CarteDAOJPAImpl"/>
     
    </beans>
    *****************************************************************************



    POUR CELLE DE POSTGRES J AI JUSTE CHANGE LES PARTIES QUI ONT UN RAPPORT AVEC PostGres:
    =========================================================================
    Code xml : 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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     
            <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
                    <property name="driverClass" value="org.postgresql.Driver"/>
                    <property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/Cards"/>
                    <property name="user" value="toto" />
                    <property name="password" value="1234" />
                    <property name="maxPoolSize" value="10" />
                    <property name="minPoolSize" value="1" />
                    <property name="maxIdleTime" value="5000" />
            </bean>
     
            <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                    <property name="dataSource" ref="dataSource" />
                    <property name="jpaVendorAdapter">
                            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                                    <property name="generateDdl" value="false" />
                                    <!--<property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />-->
                                    <property name="databasePlatform" value="org.hibernate.dialect.ProgressDialect" />
                            </bean>
                    </property>
            </bean>
     
            <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
     
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
     
        <tx:annotation-driven />
     
        <bean id="carteDaoJpaImpl" class="com.viveris.vizada.soapServices.model.carte.CarteDAOJPAImpl"/>
     
    </beans>
    ===========================================================================

  2. #2
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    Pourquoi utilises tu le dialect ProgressDialect pour Postgres
    Rien à voir.

  3. #3
    Membre éprouvé Avatar de we.are.the.storm
    Profil pro
    Inscrit en
    Février 2009
    Messages
    115
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 115
    Par défaut
    Bonjour,

    Je vois deux éléments qui pourraient poser problème :
    1. As-tu récupéré et installé le connecteur JDBC de Postgres ?
    2. Essaye en ajoutant la property dialect=org.hibernate.dialect.PostgreSQLDialect dans ton datasource.

  4. #4
    Membre Expert
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 963
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 963
    Par défaut
    Citation Envoyé par we.are.the.storm Voir le message
    Bonjour,

    Je vois deux éléments qui pourraient poser problème :
    1. As-tu récupéré et installé le connecteur JDBC de Postgres ?
    2. Essaye en ajoutant la property dialect=org.hibernate.dialect.PostgreSQLDialect dans ton datasource.
    et une fois que vous aurez régler ces problèmes :

    faites attention si vous avez des attributs de type BigDecimal dans vos classes … que les types DB entre ORACLE et PostgreSQL ne posent pas de problème lors de la conversion des données question précision après la virgule…

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 4
    Par défaut
    Merci pour vos réponses rapides.
    J'ai en effet fais attention à téléchager le jdbc adéquat et contrairement à ce qui apparait dans la conf que j'ai présenté, j'ai bien utiliser le bon dialectique:
    org.hibernate.dialect.PostgreSQLDialect.

  6. #6
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 4
    Par défaut
    Re Bonjour à tous
    En faisant des tests je me suis rendu compte d'une légère subtilité. En effet en fonction du Datasource que j' utilise tomcat réagit différemment.

    Par exemple avec le dbcp:
    ============================================================
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClass" value="org.postgresql.Driver"/>
    <property name="jdbcUrl" value="jdbc:postgresql://localhost/Cards"/>
    <property name="user" value="toto"/>
    <property name="password" value="1234"/>
    <property name="maxPoolSize" value="10"/>
    <property name="minPoolSize" value="1"/>
    <property name="maxIdleTime" value="5000"/>
    </bean>
    ==============================================================
    Il se lance maiss n'arrive pas à déployer l'application


    Avec le ComboPool
    ===========================================================
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="org.postgresql.Driver"/>
    <property name="jdbcUrl" value="jdbc:postgresql://localhost/Cards"/>
    <property name="user" value="toto" />
    <property name="password" value="1234" />
    <property name="maxPoolSize" value="5" />
    <property name="minPoolSize" value="1" />
    <property name="maxIdleTime" value="5000" />
    </bean>
    =============================================================

    Contrairement au DBCP, le tomcat ne se lance pas.


    J'espère que ces informations supplémentaires pourront vous aider à mieux comprendre le problème face auquel je me trouve.

    Merci de votre aide

Discussions similaires

  1. faire une importation/liaison d'une base Oracle vers sql server
    Par batou22003 dans le forum Développement
    Réponses: 19
    Dernier message: 07/07/2010, 09h28
  2. Plus-value d'une certification Oracle PL/SQL
    Par Glutinus dans le forum Oracle
    Réponses: 4
    Dernier message: 01/06/2010, 11h36
  3. Problème de connexion à une base oracle avec SQL PLUS en mode graphique
    Par Bayfall dans le forum Connexions aux bases de données
    Réponses: 0
    Dernier message: 24/01/2010, 17h34
  4. pilotes odbc pour linux pour attaquer une BD oracle et sql S
    Par mloul dans le forum Décisions SGBD
    Réponses: 2
    Dernier message: 08/12/2004, 15h58

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