eclipse快捷键 自己使用简单总结
ctrl+shift+O 清理代码引用的多余类
ctrl+shift+R 打开指定文件
ctrl+shift+O 清理代码引用的多余类
ctrl+shift+R 打开指定文件
//hibernate 返回对象指定属性,需要返回的列,可以直接返回 对象属性 @OverridepublicTeamPlan getTeamPlanByBaoMingId(String baomingid){
Criteria cr=this.getSession().createCriteria(BaoMingInfo.class);
cr.setProjection(Projections.property("teamplan"));//需要返回的列,可以直接返回 对象属性 cr.add(Restrictions.eq("id", baomingid));//条件 return(TeamPlan)cr.uniqueResult();
}
@OverridepublicInteger getSumBaseXuNiZuoWeiByTpid(String teamPlanID){
String hql="select sum(basexunizuoweishu) from TeamPlanXuNiZuoWeiEntity where teamplanid=:teamplanid";
Query query=this.getSession().createQuery(hql);
query.setString("teamplanid", teamPlanID);return(Integer)query.uniqueResult();
}
这种方式serviceImpl 方法不用throws异常,比较方便if(count>0){//或者 IllegalArgumentException java的 throw new IllegalArgumentException("msg");//这个是poi的异常 throw new IllegalPropertySetDataException("msg");
}
前台得到后台定义的异常字符串
}catch(Exception e) {
message=e.getMessage();
e.printStackTrace();
}
usemastergo create proc KillSpByDbName(@dbname varchar(20))as begin declare @sql nvarchar(500),@temp varchar(1000)declare @spid int set @sql='declare getspid cursor for
select spid from sysprocesses where dbid=db_id('''+@dbname+''')' exec (@sql)opengetspidfetch next from getspid into @spid while @@fetch_status <>-1 begin set @temp='kill'+rtrim(@spid)exec(@temp)fetch next from getspid into @spid end closegetspiddeallocategetspidend --举例使用,关闭数据库下的所有连接操作 UsemasterExec KillSpByDbName 'bafangmsh'
/*** 得到指定日期 + 几个小时后的日期
* 参数都必须,否则返回null
*@paramdate 需要增加小时数 的日期
*@paramhour 增加小时数
*@return */ public static Date getAddSomeHoursDate(Date date,inthour){if(date!=null && hour!=0){//SimpleDateFormat sf = new SimpleDateFormat(patternStr); Calendar ca=Calendar.getInstance();
ca.setTime(date);
ca.add(Calendar.HOUR_OF_DAY, hour);//System.out.println(sf.format(ca.getTime())); returnca.getTime();
}else{return null;
}
}