Code example for ResultSet

Methods: close, getString, next

0
    private void butSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butSearchActionPerformed
        try { 
            String sql2 = "select * from doctors where doctorId='" + txtDoctorId.getText() + "'";
            ResultSet rst = stm.executeQuery(sql2);
 
            if (rst.next() == false) {
                JOptionPane.showMessageDialog(this, "No Record Found!", "Open MRM System", javax.swing.JOptionPane.INFORMATION_MESSAGE);
                return; 
            } else { 
                txtDoctor.setText(rst.getString("doctor"));
                txtSpecialty.setSelectedItem(rst.getString("Specialty"));
                txtFees.setText(rst.getString("fees"));
                txtTp.setText(rst.getString("tpno"));
            } 
            rst.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Error Occured!", "Open MRM System", javax.swing.JOptionPane.ERROR_MESSAGE);
        } 
    }//GEN-LAST:event_butSearchActionPerformed 
 
    private void txtDoctorIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDoctorIdActionPerformed