0
I’m having a problem when running my program and have no idea what might be wrong, I made a Java program with Annotations. Would anyone know to tell me?
[Fatal Error] :8:83: The "Property" element 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:/Programming/Programs/Java/Gametest/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 "Property" element type must be followed by 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 I’m 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>
It worked, thank you very much :D
– Guilherme Souza