找到方法了,用pstmt.setTimestamp就可以了

解决方案 »

  1.   

    数据库表中对应时间的那个字段的类型设为varchar型(指mysql),设字段名为:curTime,然后在代码中用SimpleDateFormat fmt= new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");
    Date currentTime = new Date();
    String dateString = fmt.format(currentTime);
    pstmt.setCurTime(2,dateString)
    这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值);
      

  2.   

    数据库表中对应时间的那个字段的类型设为varchar型(指mysql),设字段名为:curTime,然后在代码中用SimpleDateFormat fmt= new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");
    Date currentTime = new Date();
    String dateString = fmt.format(currentTime);
    pstmt.setCurTime(2,dateString)
    这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值);
      

  3.   

    数据库表中对应时间的那个字段的类型设为varchar型(指mysql),设字段名为:curTime,然后在代码中用SimpleDateFormat fmt= new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");
    Date currentTime = new Date();
    String dateString = fmt.format(currentTime);
    pstmt.setCurTime(2,dateString)
    这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值);
      

  4.   

    解决了好,恭喜,setTimestamp是可以的