我试图将数据直接插入到我的数据库中(在主机上)并通过sqlcommand轻松地将其标识(插入值..etc),当我尝试对更新语句执行相同操作时它不起作用..为什么??
btnpunchin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd _ HH:mm:ss");
String currentDateandTime = sdf.format(new Date());
try {
Connection con = connectionClass.CONN();
if (con == null) {
z = "there is something wrong ";
} else{
Toast.makeText(attendance.this, "Punch-in successful!!!" ,Toast.LENGTH_SHORT).show();
Statement st = con.createStatement();
st.executeUpdate("UPDATE att" +
"SET name='yo' WHERE id= 404340 );");
st.executeUpdate("INSERT INTO att " +
"VALUES ('3' , '"+ currentDateandTime+"' , '4002' , GETDATE() )");
con.close();
}
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
}
});