Java论坛网»Java技术»用hql如何向oracle数据库写入date型数据?
用hql如何向oracle数据库写入date型数据?
问?:
我在oracle中建立了一个表,其中有一个字段时date型的,外用this.getHibernateTemplate().saveOrUpdate(bactivity);向表中写数据的时候中是出问题
我用的是java.sql.Date.valueOf把string转换成date类型的比如 “2006-09-02”
转换没问题,就时没办法写入数据库
还有在oracle中只有输入2006/09/02才能输入,用2006-09-02提示错误
请高手指点!!!!
我用的是java.sql.Date.valueOf把string转换成date类型的比如 “2006-09-02”
转换没问题,就时没办法写入数据库
还有在oracle中只有输入2006/09/02才能输入,用2006-09-02提示错误
请高手指点!!!!
答!: 1:
报的错误是
Hibernate operation: could not get next sequence value; bad SQL grammar [select hibernate_sequence.nextval from dual]; nested exception is java.sql.SQLException: ORA-02289: 順序が存在しません。
Hibernate operation: could not get next sequence value; bad SQL grammar [select hibernate_sequence.nextval from dual]; nested exception is java.sql.SQLException: ORA-02289: 順序が存在しません。
答!: 2:
还有如何把string型的2006/09/02装换成date型的
答!: 3:
to_date('" + time + "','yyyy-mm-dd hh24:mi:ss')
time是你的时间(string型)
time是你的时间(string型)
答!: 4:
报的错误是序列不存在,和日期没关系的说
答!: 5:
Calendar today = Calendar.getInstance();
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time = formatter1.format(today.getTime());
这种格式就是楼主所要得到的yyyy-mm-dd如果不要小时,分钟,即后面的"hh:mm"可以不要
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time = formatter1.format(today.getTime());
这种格式就是楼主所要得到的yyyy-mm-dd如果不要小时,分钟,即后面的"hh:mm"可以不要
答!: 6:
hql里写成oracle认识的类型即可,pl/sql里怎么写,程序里就照套
相关JAVA教程:
Hibernate异常请指教
请帮忙分析一下:axis1.4编写的web service client
部署webService出错
hibernate+spring的问题
poi.jar在哪下载啊?
axis问题,编译成功,在JBuilder里面也可以运行,但是export出来.exe,单独运行时候会有以下异常
struts中传值给form时得到乱码
java做MDI窗口是否不能使用singleton模式
急!!关于错误提示的问题~?
谁给个resin3.0.19 windows版本---100分相赠
发现JAVA的开源BLOG还是不错的,大家进来瞧瞧~
JBoss配置数据源问题