BM_DNS

http://pt.stackoverflow.com/questions/173435

Dec 25th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. public class LoginDAO {
  2.    
  3.     private static final String SQL_CONSULTA = "SELECT * FROM usuarios WHERE nome_usuario = ? AND senha_usuario = ?";
  4.  
  5.     public void search(Login l) {
  6.  
  7.         try (Connection conn = JavaConnect.connectDb(); PreparedStatement pstmt = conn.prepareStatement(SQL_CONSULTA);) {
  8.             pstmt.setString(1, l.getNome());
  9.             pstmt.setString(2, l.getSenha());
  10.             pstmt.executeQuery();
  11.         } catch (SQLException ex){
  12.             JOptionPane.showMessageDialog(null, "Erro ao inserir dados no DataBase.");
  13.         } finally{
  14.             JavaConnect.DesconnectDb(l, pstmt);
  15.         }
  16.     }
  17. }
Add Comment
Please, Sign In to add comment