Advertisement
Guest User

Untitled

a guest
May 29th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public class Acesso {
  2.  
  3. public boolean acesso;
  4.  
  5. public void Acessar (String login, String senha){
  6. Connection conexao = null;
  7. Statement stmt = null;
  8. ResultSet tabela = null;
  9.  
  10.  
  11. try{
  12. Class.forName("com.mysql.jdbc.Driver");
  13. conexao = DriverManager.getConnection("jdbc:mysql://127.0.0.1/cadastro_potato", "root", "");
  14. stmt = (Statement) conexao.createStatement();
  15. tabela = stmt.executeQuery("select login, senha from usuario where login ='"+ login + "'and senha ='"+senha+"'");
  16.  
  17. if(tabela.next()){
  18.  
  19. acesso = true;
  20. }else{
  21. JOptionPane.showMessageDialog(null, "Usuário e Senha Incorretos");
  22. acesso = false;
  23. }
  24.  
  25.  
  26. }catch(ClassNotFoundException | SQLException ex){
  27.  
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement