hibernate根据时间日期来查询oracle数据库
使用模糊查询:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
Date startdate = sdf.parse(start_date);
Date enddate = sdf.parse(end_date);
List list = sess.createCriteria(MyTabel.class)
.add( Restrictions.eq("clinid", start_clinId) )
.add( Restrictions.between("idate", startdate, enddate) ) .list();
使用oracle本身的函数
session.find("from Weather w where w.recordTiime=to_date('"+ datestr +"', 'yyyy-mm-dd hh24:mi:ss')")
其中datestr是形如"2005-03-01 11:30:00"格式的字符串
Spring集成hibernate
public List findResult(final String bankid,final String begintime,final String endtime) {
log.debug("finding Result Ydopehb instances");
java.util.Date bd=DateUtil.getDate(begintime);
java.util.Date ed=DateUtil.getDate(endtime);
java.sql.Date bdate = new java.sql.Date(bd.getTime());
java.sql.Date edate = new java.sql.Date(ed.getTime());
try {
String queryString = "from Ydopehb where bankid='"
+ bankid +"' and feetime between :begintime and :endtime ";
return getHibernateTemplate().findByNamedParam(queryString, new String[]{"begintime","endtime"}, new java.sql.Date[]{bdate,edate}) ;
} catch (RuntimeException re) {
log.error("find Result failed", re);
throw re;
}
}
其中DateUtil 是自定义的工具类,用来在Date类型和String类型之间互相转换。
相关文档:
@@servername:返回运行SQL Server数据库本地服务器的名称。
@@remserver:返回登录记录中记载的远程SQL Server服务器的名称。
@@connections:返回自上次启动SQL Server以来连接或试图连接的次数,用其可让管理人员方便地了解今天所有试图连接服务器的次数。
@@cursor_rows:返回最后连接上并打开的游标中当前存在的合格 ......
ceil(number) 大于或等于的最小整数
floor(number) 小于或等于的最大整数
trunc(number,m) 在整数number的m位置截掉m及以后的位数:
如:trunc(15.78,1)=15.7
trunc(15.78,-1)=15;
round ......
oracle constraints 应用
oracle constraints可以设置为立即检查或者当时事务提交时检查。
可以在创建约束的时候指定是deferrable。然后通过set constraints xxx set deferred或者immediate,也可以在seesion级别设定所有约束为deferred或者immediate(alter seesion set constraints deferred/immediat ......
一.资源需要:
至少1024 MB物理内存
1024-2048 需1.5倍的交互空间
2048-8192 需1倍的交互空间
8192- 需0.75倍的交互空间
至少400 MB /tmp 临时目录空间
oracle软件需要1.5 GB 到 3.5 GB 磁盘空间
默认数据库需要1.2 GB
二.查看系统资源相关语 ......
1.概述
索引是应用设计和开发的一个重要方面。如果有太多的索引,DML 的性能就会受到影响。如果索引太
少,又会影响查询(包括插入、更新和删除)的性能。要找到一个合适的平衡点,这对于应用的性能至关
重要。
我常常发现,人们在应用开发中总是事后才想起索引。我坚持认为这是一种错误的做法。如果你知
道数据将如何 ......