1、数据库中的date列,在模型图的实体属性中、后台Bean的value绑定中,都要申明为java.sql.Date类型,才能正常使用;
如都申明为String,或实体属性String、Bean中Date,则gl中报错如下:
Caused by: java.sql.SQLDataException: ORA-01861: 文字与格式字符串不匹配
2、 在sql plus中执行sql语句报错如下:[Err] ORA-00984: column not allowed here
原因:字符串没有用单引号,或者错误的用了双引号
3、The attribute [BGSJ] from the entity class [class maWei.sciMan.sciInfo.academic] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.
原因:oracle中,数据库中的Date字段,一般在ejb或JDBC中应映射为java.sql.date(只有日期,没有时间)。如果映射为java.util.date(有日期和时间)
解决:则应在在实体类中该字段的定义上添加 @Temporal(TemporalType.DATE)
4、Internal Exception: java.sql.SQLDataException: ORA-01861: 文字与格式字符串不匹配
原因:oracle中,数据库中字段为date,jdbc插入类型为string
解决:
a、插入时在sql中使用nativeQuery,to_date()将string转化为date
b、将字段映射为java.sql.timestamp,xhtml中的w:dateTimeField设置为java.util.date,bean中进行转换如下:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
t.setBGSJ(Timestamp.valueOf(df.format(BGSJ_value)));