static void signUp(String u,String p,String cp)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter User Name");
u=sc.nextLine();
Session s = HIBDAOLayer.getSession();
Criteria c =s.createCriteria(table.Login.class);
c.add(Restrictions.eq("lid", u));
List<Login> data = c.list();
if(data.size()>0)
System.out.println("Username Already Exist/nPlease Choose another user name");
else
{
System.out.println("Enter Password");
p=sc.nextLine();
System.out.println("Confirm Your Password");
cp=sc.nextLine();
//e.setSalary(sal);
if(p.equals(cp))
{
Login l = new Login();
// l.setLastlogin();
l.setLid(u);
l.setPass(p);
// Session s = HIBDAOLayer.getSession();
Transaction t = s.beginTransaction();
s.save(l);
t.commit();
System.out.println("You Are Successfully Registered With Us");
}
else
System.out.println("Password Doesn't Match");
}
我的表包含四个属性lid,pass,role,lastlogin,其中role和lastlogin是默认值。
我认为问题在于lastlogin的数据类型是时间戳,默认是CURRENT_TIMESTAMP。