{
Usuarios_DAO_W1 usuario = null;
EntityManagerFactory emf = null;
EntityManager em = null;
Query query = null;
try {
emf = Persistence.createEntityManagerFactory("itcmedbr_PU");
em = emf.createEntityManager();
EntityTransaction transct = em.getTransaction();
query = em.createQuery(
"select i from Usuarios i where i.Apelido = ?1 and Senha = ?2 and cnpj = ?3"
);
query.setParameter(1, Apelido);
query.setParameter(2, Senha);
query.setParameter(3, CNPJ);
em.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Caiu no catch senha invalida....");
log.info("Retorno: " + usuario);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<br>");
out.println("<h1>PacientesDAO - Usuário ou senha invalido!</h1>");
out.println("</body>");
out.println("</html>");
out.close();
} finally {
if ( em != null ) {
em.close();
}
if ( emf != null ) {
emf.close();
}
}
return usuario;
}
"
I appreciate any help.
Thanks and best regards.
@Table(name = "tabela_profissional_medico")
@Access(value = AccessType.FIELD)
@Entity(name = "Usuarios")
public class Usuarios_DAO_W1 implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "IND")
private Integer ind;
@Column(name = "CNPJ")
private String cnpj;
@Column(name = "Nome")
private String nome;
@Column(name = "Apelido")
private String apelido;
@Column(name = "Email")
private String email;
@Column(name = "Cremerj")
private String cremerj;
@Column(name = "Coren")
private String coren;
@Column(name = "Senha")
private String senha;
@Column(name = "Tipo")
private String tipo;
@Column(name = "Celular")
private String celular;
.......
GETTERS, SETTERS And TOSTRING
public Usuarios_DAO_W1 getLoginW0(String Apelido, String Senha, String CNPJ) throws Exception
{
Usuarios_DAO_W1 usuario = new Usuarios_DAO_W1();
EntityManagerFactory emf = null;
EntityManager em = null;
Query query = null;
try {
emf = Persistence.createEntityManagerFactory("itcmedbr_PU");
em = emf.createEntityManager();
EntityTransaction transct = em.getTransaction();
return (Usuarios_DAO_W1) em.createQuery(
"FROM Usuarios i where i.Apelido = :apelido AND i.Senha = :senha AND i.CNPJ = :cnpj")
.setParameter("apelido", Apelido)
.setParameter("senha", Senha)
.setParameter("cnpj", CNPJ);
} catch (Exception e) {
e.printStackTrace();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<br>");
out.println("<h1>PacientesDAO - Usuário ou senha invalido!</h1>");
out.println("</body>");
out.println("</html>");
out.close();
} finally {
if ( em != null ) {
em.close();
}
if ( emf != null ) {
emf.close();
}
}
return usuario;
}
"
Thanks by assistance.
<subsystem xmlns="urn:jboss:domain:logging:1.0">
<console-handler name="CONSOLE">
<level name="TRACE" />
...
</console-handler>
...
<logger category="org.hibernate.SQL">
<level name="TRACE" />
</logger>--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/2af9bd69-d931-489f-a8da-25718766a5ecn%40googlegroups.com.