SSH框架中,spring xml定时调用存储过程定时任务配置示例及代码主要流程示例,简单版
主要代码示例
<!-- 刷新EHR用户角色 --> <bean id="synRoleId" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"> <ref bean="webService" /> </property> <property name="targetMethod"> <value>updateRoleId</value> </property> <property name="concurrent" value="false"/> </bean> <bean id="synRoleIdTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"> <ref bean="synRoleId" /> </property> <property name="cronExpression"> <value>0 00 05 ? * *</value> </property> </bean> <!-- 启动job --> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref local="synRoleIdTrigger" /> <!-- 配置多个定时任务--> </list> </property> <property name="autoStartup" value="true"/> </bean> 接口类中: public void snycUpdateRoleId(); 接口实现类中: @Override public void updateRoleId() { log.info("CALC.SP_UPDATE_ROLE_ID..."+new Date()); this.syUserDAO.updateBySQL("{call CALC.SP_UPDATE_ROLE_ID()}"); } hibernate调用方法: public Integer updateBySQL(final String sql, final Object... paramsValue) { return (Integer)getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createSQLQuery(sql); if(paramsValue!=null){ for (int i = 0; i < paramsValue.length; i++) { query.setParameter(i, paramsValue[i]); } } return query.executeUpdate(); } }); }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8005.html