0

I can't connect to the database and I can't find the problem

persistence file :

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_0.xsd ">
  <persistence-unit name="UP_GAB" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name= "hibernate.show_sql" value= "true"/>
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
        </properties>
    </persistence-unit>
</persistence>

contexte file :

<?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:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

        <bean id="datasource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
        <property name="connectionCachingEnabled" value="true"/>
        <property name="URL" value="jdbc:oracle:thin:localhost:1521:GAB"/>
        <property name="user" value="issam"/>
        <property name="password" value="*****"/>
</bean>

<bean id= "persistenceUnitManager" class= "org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
        <property name= "persistenceXmlLocations">
        <list>
        <value>classpath*:META-INF/persistence.xml</value>
        </list>
        </property>
        <property name= "defaultDataSource" ref= "datasource"></property>
</bean>
<bean id= "entityManagerFactory" class= "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name= "persistenceUnitManager" ref= "persistenceUnitManager"></property>
<property name= "persistenceUnitName" value= "UP_GAB"></property>
</bean>
<bean id="transactionManager" class= "org.springframework.orm.jpa.JpaTransactionManager">
<property name= "entityManagerFactory" ref= "entityManagerFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

Database Information:

connection name: Gab
user name: issam
host name: localhost
port: 1521
SID: Gab

and this is the dependency in the pom.xml file :

       <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.4.0</version>
        </dependency>

NB : i have Oracle 11 g not phpmyadmin

Thanks for your help !

Ism Ze
  • 1
  • 5
  • 2
    `` => will ony validate the database, doesn't make changes. Be sure to read the docs before choosing a value. – Tome Aug 03 '15 at 16:56
  • Voted to close as duplicate as this question won't help other users in the future - possible duplicate of [How to create database schema in hibernate first time and further update it in case of schema modification?](http://stackoverflow.com/questions/8815037/how-to-create-database-schema-in-hibernate-first-time-and-further-update-it-in-c) – Augusto Aug 03 '15 at 21:54
  • **is not duplicated , i have problem with connection between oracle and Maven not sql (phpmyadmin) !!** – Ism Ze Aug 04 '15 at 08:16

1 Answers1

0

Property should be:
property name="hibernate.hbm2ddl.auto" value="create"

Daniel Jipa
  • 878
  • 11
  • 24
  • when i changed the value to create a new problem appeared : java.lang.AssertionError: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContexte.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: UP_GAB] Unable to build EntityManagerFactory – Ism Ze Aug 04 '15 at 08:22