Error in persistence.xml when connecting oracle database

Asked

Viewed 111 times

0

I have this file to perform oracle database persistence. However 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>

1 answer

1


As mentioned in the comments, your settings use Mysql and not 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.

  • 1

    am downloading the version : ojdbc14.jar!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.