Could you solve for me this if the code is correct

int as[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String s=jTextField1.getText();
String sp=jTextField10.getText();
if (s.equals(“”) && sp.equals(“”)) {
JOptionPane.showMessageDialog(this, “Please enter data in mandatory fields”);
} else {
try {
Class.forName(“com.mysql.jdbc.Driver”);
Connection conn = DriverManager.getConnection(“jdbc:mysql://localhost:3306/Clinic?zeroDateTimeBehavior=convertToNull”, “root”, “”);
Statement stmt = conn.createStatement();
String query;
String pid, fname, lname, gender, dob, blood_group, HNo, street, city, state, phn1, phn2, email;
int doc_id;
fname = jTextField1.getText();
lname = jTextField15.getText();
pid = jTextField9.getText();
gender = “Male”;
if (jRadioButton2.isSelected() == true) {
gender = “Female”;
}
int a = jComboBox3.getSelectedIndex() + 1;
int count=0;
query = “Select COUNT(empid) from employee where deptid=” + a + “;”;
System.out.println(“”+query);
ResultSet rs = stmt.executeQuery(query);
if(rs.next()){
count = rs.getInt(1);
}
if (count == 0) {
JOptionPane.showMessageDialog(null, “No Doctor Available!”);
} else {
query = “Select empid from employee where deptid=” + a + “;”;
rs = stmt.executeQuery(query);
System.out.println(“”+query);
as[a-1] = (as[a – 1] + 1) % (count+1);
int b = as[a – 1];
System.out.println(“”+b);
for (int x = b; x >0; x–) {
rs.next();
}
doc_id = rs.getInt(1);
System.out.println(“”+doc_id);
dob = jTextField10.getText();
blood_group = jComboBox1.getSelectedItem().toString();
HNo = jTextField4.getText();
street = jTextField5.getText();
city = jTextField2.getText();
state = jTextField3.getText();
phn1 = jTextField6.getText();
phn2 = jTextField7.getText();
email = jTextField8.getText();

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.