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ÀàÐÍÖ®¼ä»¥Ïàת»»¡£
Ïà¹ØÎĵµ£º
ѧϰOracle DBAÒ²°ë¸ö¶àѧÆÚÁË£¬½ñÌìÃÍÈ»²Å·¢ÏÖ£¬ÔÀ´ÎÒµÄÊ黹ÊǺÜеģ¬ÉϿβÙ×÷ʱºòÒ²Ö»ÊÇÖªµÀ´ó¸ÅÔõô×ö£¬µ«ÊÇÒªÕæµÄÈ«²¿×Ô¼º×ö£¬¶ø²»È¥·Ê黹ÊÇÓÐÒ»¶¨µÄÄѶȵģ¬ËùÒÔÄØ£¬½ñÌ쿪ʼ½«DBA´ÓÍ·¸´Ï°Ò»±é£¬Í¬Ê±ÔÙ²Ù×÷Ò»±é¡£
µÚÒ»Õ£¬Ñ§µÄÊÇOracleµÄÌåϵ½á¹¹£ ......
ÉÌÒµ¿ªÔ´Êý¾Ý¿â³§¼ÒEnterpriseDBÓë6ÔÂ17ÈÕ·¢²¼ÁË×îеÄPostgres Plus¸ß¼¶·þÎñÆ÷°æ£¬ÆäÄ¿±êÊÇÌá¸ßÓëOracleÊý¾Ý¿âµÄ¼æÈÝÐÔ£¬EnterpriseDBÊÇ¿ªÔ´Êý¾Ý¿âPostgreSQL£¨Ò²½Ð×öPostgres£©±³ºóµÄÖ÷ÒªÉÌÒµÖ§³Ö¹«Ë¾¡£
ÆäʵPostgres Plus¸ß¼¶·þÎñÆ÷°æ²¢·ÇÍêÈ«¿ªÔ´£¬ËüÊÇÔÚ¿ªÔ´µÄPostgreSQLÊý¾Ý¿â»ù´¡Ö®ÉÏÌí¼ÓÁËÐí¶à¸½¼ÓÌØÐÔ£¬ÒÔÌá¸ßºÍO ......
ºÙºÙ£¬Õ⻹ÊÇÉÏÕÂ֪ʶÁË£¬Ö»Êǵ¥Ò»Ð´³öÀ´±È½ÏºÃÒ»µã£¬ÒòΪÉÏÃæµÄÊǽϻù´¡µÄ£¬²»ÔõôÉæ¼°²Ù×÷£¬¶øÕâÀïÊÇͨ¹ý²Ù×÷³öÀ´µÄ£¬ºÇºÇ¡£
Ê×ÏÈ£¬´ò¿ªÊý¾Ý¿â·þÎñ£¬È»ºóͨ¹ý¿ØÖÆ̨´ò¿ªsqlplus£º
È»ºó½«Êý¾Ý¿âÉèÖÃΪֻ¶Á£ºalter database read only£»µ«ÊÇÄØ£¬ÕâÑùÊDz»Ä ......
1.¸ÅÊö
Ë÷ÒýÊÇÓ¦ÓÃÉè¼ÆºÍ¿ª·¢µÄÒ»¸öÖØÒª·½Ãæ¡£Èç¹ûÓÐÌ«¶àµÄË÷Òý£¬DML µÄÐÔÄܾͻáÊܵ½Ó°Ïì¡£Èç¹ûË÷ÒýÌ«
ÉÙ£¬ÓÖ»áÓ°Ïì²éѯ£¨°üÀ¨²åÈë¡¢¸üкÍɾ³ý£©µÄÐÔÄÜ¡£ÒªÕÒµ½Ò»¸öºÏÊʵÄƽºâµã£¬Õâ¶ÔÓÚÓ¦ÓõÄÐÔÄÜÖÁ¹Ø
ÖØÒª¡£
ÎÒ³£³£·¢ÏÖ£¬ÈËÃÇÔÚÓ¦Óÿª·¢ÖÐ×ÜÊÇʺó²ÅÏëÆðË÷Òý¡£ÎÒ¼á³ÖÈÏΪÕâÊÇÒ»ÖÖ´íÎóµÄ×ö·¨¡£Èç¹ûÄãÖª
µÀÊý¾Ý½«ÈçºÎ ......
declare
v_isexist number(3,0):=0;
begin
select count(1) into v_isexist from sys.all_objects where owner = 'TEST' and object_type = 'TABLE' and object_name = 'TAB1';
if v_isexist>0 ......