I'm new to Java. I'm trying to create an example of JPA.
src / META-INF / persistence.xml
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost:3306/meubancodados?autoReconnect=true&useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="*********" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
ProductProduct.java
package br.com.treinoweb.jee.models;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "TRP_TIPOS_PRODUTO")
public class TipoProduto {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "TRP_ID")
private int id;
@Column(nullable = false, length = 100, name = "TRP_NOME_TIPO_PRODUTO")
private String nome;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
ListTypeProducts.jsp
<%
EntityManagerFactory factory = Persistence.createEntityManagerFactory("TwPersistenceUnit");
EntityManager entityManager = factory.createEntityManager();
Query qry = entityManager.createQuery("SELECT tp FROM TipoProduto"); //selecionar tudo
List<TipoProduto> proList = qry.getResultList();
%>
HTTP Status 500 - Internal Server Error
Type Exception Report
Message An exception occurred processing [jpa / listTypeProducts.jsp] at line [35]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception org.apache.jasper.JasperException: An exception occurred processing [jpa / listTypeProducts.jsp] at line [35]
32: