Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dao;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import javax.swing.JOptionPane;
- import java.sql.Statement;
- public class Acesso {
- public boolean acesso;
- public Acesso(String nome, String cpf) {
- Connection con = null;
- Statement consulta = null;
- ResultSet tabela = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection("jdbc:mysql://localhost/farmaciatargaryen",
- "root", "root");
- consulta = (Statement) con.createStatement();
- tabela = ((java.sql.Statement) consulta)
- .executeQuery("select nome, cpf from adm_usuario where nome='"
- + nome + "'and cpf='" + cpf + "'");
- if (tabela.next()) {
- JOptionPane.showMessageDialog(null, "Usuario e Senha Corretos");
- acesso = true;
- }
- else {
- JOptionPane.showMessageDialog(null,
- "Usuario e Senha Incorretos");
- acesso = false;
- }
- }
- catch (ClassNotFoundException | SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement