I'm having a problem when I run my program and I have no idea what might be wrong, I did a Java program with Annotations. Could anyone tell me?
[Fatal Error]: 8: 83: Property type must be followed by attribute specifications, ">" or "/ >". Exception in thread "main" javax.persistence.PersistenceException: Unable to locate persistence units at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull (HibernatePersistenceProvider.java:84) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull (HibernatePersistenceProvider.java:71) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory (HibernatePersistenceProvider.java:52) at javax.persistence.Persistence.createEntityManagerFactory (Persistence.java:55) at javax.persistence.Persistence.createEntityManagerFactory (Persistence.java:39) at Test.main (Test.java:10) Caused by: javax.persistence.PersistenceException: Unexpected error parsing [file: / D: /Programacao/Programas/Java/GameTeste/bin/META-INF/persistence.xml] at org.hibernate.jpa.boot.internal.PersistenceXmlParser.loadUrl (PersistenceXmlParser.java:294) at org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml (PersistenceXmlParser.java:94) at org.hibernate.jpa.boot.internal.PersistenceXmlParser.doResolve (PersistenceXmlParser.java:84) at org.hibernate.jpa.boot.internal.PersistenceXmlParser.locatePersistenceUnits (PersistenceXmlParser.java:66) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull (HibernatePersistenceProvider.java:80) ... 5 more Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 83; The type of property element must be followed by the attribute specifications, ">" or "/ >". at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse (Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse (Unknown Source) at org.hibernate.jpa.boot.internal.PersistenceXmlParser.loadUrl (PersistenceXmlParser.java:289) ... 9 more
Code that I am trying to execute:
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
public class Teste {
public static void main(String[] args)
{
EntityManagerFactory entity = Persistence.createEntityManagerFactory("persistence");
EntityManager em = entity.createEntityManager();
Conta c = new Conta();
//seleciona na tabela
//c=em.find(Conta.class, 21l);
//seta o nome ao obj
c.setNome("joao");
c.setEmail("[email protected]");
c.setSenha("123");
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(c);// insert
//em.merge(c);//update
//em.remove(c);//delete
tx.commit();
em.close();
entity.close();
}
}
My persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="persistence">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"" />
<property name="hibernate.connection.url" value="jdbc:mysql://127.0.0.1/Game" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.password" value="1997" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>