The program given below is not executing the rs1(Result set query) rather it is directly moving into the catch block). I'm not able to identify the error. Help please.
private void EnterActionPerformed(java.awt.event.ActionEvent evt)
{
Calendar cal=new GregorianCalendar();
int minute =cal.get(Calendar.MINUTE);
int hours=cal.get(Calendar.HOUR);
String time1=minute+":"+hours;
String s=Login_page.id+"";
String sql="UPDATE emp_info SET intime=? where empid=?";
try
{
switch (time)
{
case "intime":
{
//"Update emp_info set intime='"+time1+"' where empid=?";
System.out.println(time+Login_page.id);
PreparedStatement pst1=conn.prepareStatement(sql);
pst.setString(1,time1);
pst.setString(2,s);
System.out.println(time+Login_page.id);
ResultSet rs1=pst.executeQuery();
if(rs.next())
{
JOptionPane.showMessageDialog(null,"In time registered");
}
break;
}
case "outtime":
{
//String sql="Insert into emp_info (outtime) values (?) where empid='"+Login_page.id+"'";
//pst=conn.prepareStatement(sql);
//pst.setString(1,time1);
//pst.setString(2,Login_page.user);
//rs=pst.executeQuery();
PreparedStatement pst2=conn.prepareStatement(sql);
pst.setString(1,time1);
pst.setString(2,s);
System.out.println(time+Login_page.id);
ResultSet rs2=pst.executeQuery();
if(rs.next())
{
JOptionPane.showMessageDialog(null,"In time registered");
}
break;
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"ERROR","ERROR",JOptionPane.WARNING_MESSAGE);
}
}