一个奇怪的日期问题(高手解答)
部分代码 数据库为oracle
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp uploadDate= Timestamp.valueOf(df.format(new java.util.Date()));
String sql="insert into repository (id,name,uploadDate,caption,type,fileSize,filePath,description) values(repository_sequence.nextVal,?,?,?,?,?,?,?)";
System.out.println(sql);
try{
pstmt = dbconn.getConnection().prepareStatement(sql);
pstmt.setString(1,name);
pstmt.setTimestamp(2,uploadDate);
pstmt.setString(3,caption);
pstmt.setString(4,type);
pstmt.setString(5,fileSize);
pstmt.setString(6,fileName);
pstmt.setString(7,description);
pstmt.executeUpdate() ;
插入时可以的日期
但是在更新操作时却不可以
数据库部分代码
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp uploadDate= Timestamp.valueOf(df.format(new java.util.Date()));
String sql="update repository set name='"+sName+"',type='"+sType+"',caption='"+sCaption+"',"+
"description='"+sDescription+"',filesize='"+fileSize+"',uploadDate='"+uploadDate+"',filePath='"+fileName+"'"+
"where id='"+id+"'";
System.out.println(sql);
try{
pstmt = dbconn.getConnection().prepareStatement(sql);
pstmt.executeUpdate() ;
不更新日期是可以更新该sql的,但是uploadDate两者打出来都是2008-04-21 09:45:14.0,打出来的sql去数据库里查不进去也,说该月份无效
为什么啊?