下面给出的程序不是执行rs1(结果集查询)而是直接进入catch块。我无法识别错误。请帮助。
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);
}
}