timestamp 字段的格式
时间在Oracle和DB2数据库中使用TimeStamp字段,在sqlsever2000中用datatime字段
字段的格式为yyyy-MM-dd HH:mm:ss
用下面的代码来插入区分格式
注意,oracle要使用一个函数:
to_date('时间','YYYY-MM-DD HH24:MI:SS')
if(MutiDBSupportUtil.DATABASE_TYPE_ORACLE.equalsIgnoreCase(MutiDBSupportUtil.getConnectionDBType(this.getConnection()))){
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sql.append("AND WE_PARTY_ASSIGNMENT.THRU_DATE >= to_date('").append(formatter.format(thruDate1)).append("','YYYY-MM-DD HH24:MI:SS') ");
}else if(MutiDBSupportUtil.DATABASE_TYPE_DB2.equalsIgnoreCase(MutiDBSupportUtil.getConnectionDBType(this.getConnection()))){
sql.append("AND WE_PARTY_ASSIGNMENT.THRU_DATE >= '").append(thruDate1).append("' ");
}else if(MutiDBSupportUtil.DATABASE_TYPE_SQLSERVER.equalsIgnoreCase(MutiDBSupportUtil.getConnectionDBType(this.getConnection()))){
sql.append("AND WE_PARTY_ASSIGNMENT.THRU_DATE >= '").append(thruDate1).append("' ");
}
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sql.append("AND WE_PARTY_ASSIGNMENT.THRU_DATE >= to_date('").append(formatter.format(thruDate1)).append("','YYYY-MM-DD HH24:MI:SS') ");
}else if(MutiDBSupportUtil.DATABASE_TYPE_DB2.equalsIgnoreCase(MutiDBSupportUtil.getConnectionDBType(this.getConnection()))){
sql.append("AND WE_PARTY_ASSIGNMENT.THRU_DATE >= '").append(thruDate1).append("' ");
}else if(MutiDBSupportUtil.DATABASE_TYPE_SQLSERVER.equalsIgnoreCase(MutiDBSupportUtil.getConnectionDBType(this.getConnection()))){
sql.append("AND WE_PARTY_ASSIGNMENT.THRU_DATE >= '").append(thruDate1).append("' ");
}