Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Acesso {
- public boolean acesso;
- public void Acessar (String login, String senha){
- Connection conexao = null;
- Statement stmt = null;
- ResultSet tabela = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- conexao = DriverManager.getConnection("jdbc:mysql://127.0.0.1/cadastro_potato", "root", "");
- stmt = (Statement) conexao.createStatement();
- tabela = stmt.executeQuery("select login, senha from usuario where login ='"+ login + "'and senha ='"+senha+"'");
- if(tabela.next()){
- acesso = true;
- }else{
- JOptionPane.showMessageDialog(null, "Usuário e Senha Incorretos");
- acesso = false;
- }
- }catch(ClassNotFoundException | SQLException ex){
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement