Error in persistence.xml when connecting oracle database

0

I have this file to perform oracle database persistence. But do not connect!

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
   <persistence-unit name="app_crud_cliente">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <class>br.com.model.ClienteModel</class>
      <properties>
         <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
         <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/bd_cliente" />
         <property name="javax.persistence.jdbc.user" value="DBA" />
         <property name="javax.persistence.jdbc.password" value="DBA" />
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
      </properties>
   </persistence-unit>
</persistence>
    
asked by anonymous 16.01.2018 / 15:40

1 answer

1

As quoted in the comments, your settings use MySQL instead of Oracle.

To use Oracle do:

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
   <persistence-unit name="app_crud_cliente">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <class>br.com.model.ClienteModel</class>
      <properties>
         <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
         <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@ip:porta/nome-da-instancia" />
         <property name="javax.persistence.jdbc.user" value="DBA" />
         <property name="javax.persistence.jdbc.password" value="DBA" />
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
      </properties>
   </persistence-unit>
</persistence>

Note: the dialect may change depending on your version of Oracle.

    
16.01.2018 / 16:18