Advertisement
Guest User

Untitled

a guest
May 16th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package dao;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import javax.swing.JOptionPane;
  8. import java.sql.Statement;
  9.  
  10. public class Acesso {
  11. public boolean acesso;
  12. public Acesso(String nome, String cpf) {
  13. Connection con = null;
  14. Statement consulta = null;
  15. ResultSet tabela = null;
  16.  
  17. try {
  18.  
  19. Class.forName("com.mysql.jdbc.Driver");
  20. con = DriverManager.getConnection("jdbc:mysql://localhost/farmaciatargaryen",
  21. "root", "root");
  22. consulta = (Statement) con.createStatement();
  23. tabela = ((java.sql.Statement) consulta)
  24. .executeQuery("select nome, cpf from adm_usuario where nome='"
  25. + nome + "'and cpf='" + cpf + "'");
  26. if (tabela.next()) {
  27. JOptionPane.showMessageDialog(null, "Usuario e Senha Corretos");
  28. acesso = true;
  29. }
  30. else {
  31. JOptionPane.showMessageDialog(null,
  32. "Usuario e Senha Incorretos");
  33. acesso = false;
  34. }
  35. }
  36. catch (ClassNotFoundException | SQLException e) {
  37. e.printStackTrace();
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement