晕,Oracle不能直接把string当成date用的,又不是sqlserver
String sql="update repository set name='"+sName+"',type='"+sType+"',caption='"+sCaption+"',"+ 
"description='"+sDescription+"',filesize='"+fileSize+"',uploadDate=to_date('"+uploadDate+"', 'yyyy-mm-dd hh24:mi:ss'),filePath='"+fileName+"'"+ 
"where id='"+id+"'";
或者说还是用你1的方式,用占位符加上setTimestamp来做也可以

解决方案 »

  1.   

    还有个问题,用了你的uploadDate是2008-04-21 10:42:07.0打出来的,去掉.0就可以查了如2008-04-21 10:42:07
    Timestamp uploadDate这个值难道做字符串处理嘛?还是用别的办法
      

  2.   

    这个和TimeStamp的toString方法有关系,如果你要用TimeStamp,推荐还是用占位符的方式
      

  3.   

    那这条sql是这么写嘛?
    String sql="update repository set(name,type,caption,description,filesize,uploaDate,filePth) values(?,?,?,?,?,?,?) where id='"+id+"'";
    好像不对哦。。麻烦了大侠
      

  4.   

    String sql="update repository set name=?,type=?,caption=?,description=?,filesize=?,uploaDate=?,filePth=? where id=?"; 
      

  5.   

    pstmt.setTimestamp(2,uploadDate); 
      

  6.   

    不报错,处理很慢很慢,不停的loading中。。没反应,我用另一种方法把2008-04-21 10:42:07.0截断为2008-04-21 10:42:07的string,也是一样,不停的loading中。后者uploadDate=to_date('"+uploadDate+"', 'yyyy-mm-dd hh24:mi:ss'),这里的uploadDate应为日期的吧,转成string后不可以的吧,你的方法就是一直loading中没反应
      

  7.   

    代码String sql="update repository set name=?,type=?,caption=?,description=?,filesize=?,uploadDate=?,filePath=? where id=?"; 
    System.out.println(sql);
        try{
         pstmt = dbconn.getConnection().prepareStatement(sql);
         pstmt.setString(1,sName);
         pstmt.setString(2,sType);
         pstmt.setString(3,sCaption);
         pstmt.setString(4,sDescription);
         pstmt.setString(5,fileSize);
         pstmt.setTimestamp(6,uploadDate);
         pstmt.setString(7,fileName);
         pstmt.setString(8,sId);
    pstmt.executeUpdate() ;
      

  8.   

    uploadDate=to_date('"+uploadDate+"', 'yyyy-mm-dd hh24:mi:ss')
    这里uploadDate不就是日期类型的么,还能用to_date么?