Code example for ResultSet

Methods: closegetIntgetStringnext

0
        Usuario usrDept = new Usuario();
        String sql = "SELECT COD,LOGIN,SENHA FROM USUARIO WHERE LOGIN=?";
        PreparedStatement pst = this.conexao.prepareStatement(sql);
        pst.setString(1, login);
        ResultSet rs = pst.executeQuery();
        if (rs.next()) {
            usrDept.setCod(rs.getInt("COD"));
            usrDept.setLogin(rs.getString("LOGIN"));
            usrDept.setSenha(rs.getString("SENHA"));
        } 
        rs.close();
        pst.close();
        return usrDept;
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE