一:前沿

  在上一篇(http://www.cnblogs.com/wuhao1991/p/4331613.html)的博客中记载了定时的功能,但是集成是没有成功的,在这篇中,我在解释下这里的”集成的含义“,这里的集成是指:比如我有两个tomcat(tomcat1,tomcat2),然后现在我先启动tomcat1,在启动tomcat2,但是定时查询的功能在tomcat1上在执行,但是tomcat2上没有执行;此时我把tomcat1停止调,tomcat2又继续执行这个定时的功能;所以这里的集成说白了就是,定时的功能只能执行一个,这两个tomcat里卖弄是互斥的关系!

二:内容技术

  在上一篇中说过,我在配置集群的时候,老是出问题,那么现在我会把这个问题记载下来;下面进行说明吧!

application-quartz.xml配置如下

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="scheduTask" class="com.xpg.chargepile.quartz.ScheduTask"></bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<bean class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="cronExpression">
<value>0/5 * * * * ?</value>
</property>
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="scheduTask"></property>
<property name="targetMethod" value="doTask"></property>
<!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
<property name="concurrent" value="false"/>
</bean>
</property>
</bean>
</list>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="applicationContextSchedulerContextKey" value="applicationContextKey"></property>
<property name="configLocation" value="classpath:quartz.properties"></property>
<property name="autoStartup" value="true" />
</bean> </beans>

 bug如下:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in file [D:\MyEclipse\wh3\.metadata\.me_tcat7\webapps\chargepile\WEB-INF\classes\applicationContext-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean [See nested exception: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.quartz.JobPersistenceException: Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean [See nested exception: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJob(JobStoreSupport.java:1115)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$2.executeVoid(JobStoreSupport.java:1062)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3703)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3701)
at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:245)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJobAndTrigger(JobStoreSupport.java:1058)
at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:886)
at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249)
at org.springframework.scheduling.quartz.SchedulerAccessor.addTriggerToScheduler(SchedulerAccessor.java:308)
at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:235)
at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
... 25 more
Caused by: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.serializeJobData(StdJDBCDelegate.java:3083)
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.insertJobDetail(StdJDBCDelegate.java:606)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJob(JobStoreSupport.java:1112)
... 37 more

使得我照这个解决方案找了好久好久啊!所以看看下面的截图(http://www.objectpartners.com/2013/07/09/configuring-quartz-2-with-spring-in-clustered-mode/)

 就是看完这句话,我才把集成给实验成功的,现在附上正确的代码<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="jobTask" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="com.gsh.gradyate.quartz.FirstJob"/>
<property name="durability" value="true"/>
</bean> <bean id="myJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="jobTask" />
</property>
<property name="cronExpression">
<value>/ * * * * ?</value>
</property>
</bean> <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<!-- 如果lazy-init='true',则需要实例化该bean才能执行调度程序 -->
<bean id="startQuertz" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property> <property name="schedulerContextAsMap">
<map>
<!-- spring 管理的service需要放到这里,才能够注入成功 -->
<description>schedulerContextAsMap</description>
<entry key="userDao" value-ref="userDao"/>
</map>
</property> <property name="applicationContextSchedulerContextKey" value="applicationContextKey"></property>
<property name="configLocation" value="classpath:quartz.properties"></property>
<property name="autoStartup" value="true" />
<property name="triggers">
<list>
<ref bean="myJobTrigger" />
</list>
</property>
</bean>
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="scheduTask" class="com.xpg.chargepile.quartz.ScheduTask"></bean> <bean id="jobTask" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="com.xpg.chargepile.quartz.FirstJob"/>
         
    <property name="jobDataAsMap">                  <map>

                              <!-- 非spring管理的service放到这里,就可以注入进去 -->
                                <description>jobDataAsMap</description>
                             <!-- key 属性值,value 对应的bean -->
                        <entry key="uploader" value-ref="uploader" />
                      </map>
                   </property>

        <property name="durability" value="true"/>

        </bean>

       <bean id="myJobTrigger"  class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="jobTask" />
</property>
<property name="cronExpression">
<value>/ * * * * ?</value>
</property>
</bean> <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<!-- 如果lazy-init='true',则需要实例化该bean才能执行调度程序 -->
<bean id="startQuertz" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property> <property name="schedulerContextAsMap">
<map>
<!-- spring 管理的service需要放到这里,才能够注入成功 -->
<description>schedulerContextAsMap</description>
<entry key="userDao" value-ref="userDao"/>
</map>
</property> <property name="applicationContextSchedulerContextKey" value="applicationContextKey"></property>
<property name="configLocation" value="classpath:quartz.properties"></property>
<property name="autoStartup" value="true" />
<property name="triggers">
<list>
<ref bean="myJobTrigger" />
</list>
</property>
</bean>

firstjob.java:

package com.gsh.graduate.quartz;

import java.util.Date;

import org.quartz.JobExecutionContext;
import org.quartz.SchedulerContext;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component; import com.gsh.graduate.dao.UserDao;
import com.gsh.graduate.pojo.User;
@Component
@Scope(value = BeanDefinition.SCOPE_PROTOTYPE)
public class FirstJob extends QuartzJobBean { // @AutoWire
 // private UserDao userDao
private UserDao userDao;
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
} @Override
protected void executeInternal(JobExecutionContext context) {
//获取JobExecutionContext中的service对象
try {
SchedulerContext skedCtx = context.getScheduler().getContext();
userDao=(UserDao) skedCtx.get("userDao");
} catch (SchedulerException e) {
e.printStackTrace();
}
User u=userDao.getUserByID("");
System.out.println("---"+u);
System.out.println("定时开始0,1,2,3");
System.out.println(new Date());
System.out.println("定时结束,game over");
}
}

特别说明:这里面的对象必须在配置文件里面声明,在firstjob.java类中,如果你想通过这样像代码中注释的那样,自动注入会报一下错误;所以可以看下spring 通过配置向quartz 注入service(http://blog.csdn.net/whaosy/article/details/6298686)

-- :: ERROR org.quartz.core.JobRunShell.run() | Job DEFAULT.jobTask threw an unhandled Exception:
java.lang.NullPointerException
at com.gsh.graduate.quartz.FirstJob.executeInternal(FirstJob.java:)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:)
at org.quartz.core.JobRunShell.run(JobRunShell.java:)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:)
-- :: ERROR org.quartz.core.ErrorLogger.schedulerError() | Job (DEFAULT.jobTask threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
at org.quartz.core.JobRunShell.run(JobRunShell.java:)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:)
Caused by: java.lang.NullPointerException
at com.gsh.graduate.quartz.FirstJob.executeInternal(FirstJob.java:)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:)
at org.quartz.core.JobRunShell.run(JobRunShell.java:)
... more

上面第一次实验的那种bug本来有两种配置方式的,但是我在配置好了之后,实验以前的没有报bug,我都郁闷了,附加代码看看

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!---方案一->
<bean id="scheduTask" class="com.gsh.graduate.quartz.ScheduTask"></bean> <!-- 调用的对象和方法的指定 -->
<bean id="jobTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- <bean id="jobTask" class="org.springframework.scheduling.quartz.JobDetailFactoryBean"> -->
<!-- <property name="jobClass" value="com.gsh.graduate.quartz.FirstJob"/> -->
<!-- <property name="durability" value="true"/> -->
<!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
<property name="concurrent" value="false"/>
<property name="targetObject" ref="scheduTask"></property>
<property name="targetMethod" value="doTask"></property>
</bean> <bean id="myJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="jobTask" />
</property>
<property name="cronExpression">
<value>1/5000 * * * * ?</value>
</property>
</bean> <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<!-- 如果lazy-init='true',则需要实例化该bean才能执行调度程序 -->
<!-- <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> -->
<bean id="startQuertz" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property> <property name="schedulerContextAsMap">
<map>
<!-- spring 管理的service需要放到这里,才能够注入成功 -->
<description>schedulerContextAsMap</description>
<entry key="userDao" value-ref="userDao"/>
</map>
</property>
<property name="applicationContextSchedulerContextKey" value="applicationContextKey"></property>
<property name="configLocation" value="classpath:quartz.properties"></property>
<property name="autoStartup" value="true" />
<property name="triggers">
<list>
<ref bean="myJobTrigger" />
</list>
</property>
</bean> <!--方案2-->
<!-- <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<bean class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="cronExpression">
<value>0/5 * * * * ?</value>
</property>
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="scheduTask"></property>
<property name="targetMethod" value="doTask"></property>
是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程
<property name="concurrent" value="false"/>
</bean>
</property>
</bean>
</list>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="applicationContextSchedulerContextKey" value="applicationContextKey"></property>
<property name="configLocation" value="classpath:quartz.properties"></property>
<property name="autoStartup" value="true" />
</bean> --> </beans>

这是所有的代码,两种方案

三:总结,折腾了这么久终于把集成给折腾成功了啊,这是接触新鲜的东西,就是不一样啊,解决问题的能力还是有涨进的啊!继续Go!Boy,今天一下在把有关Quartz的都写了!不枉我研究了两天啊!

spring结合Quartz的集群功能实现的更多相关文章

  1. Spring Boot Quartz 分布式集群任务调度实现

    Spring Boot Quartz 主要内容 Spring Scheduler 框架 Quartz 框架,功能强大,配置灵活 Quartz 集群 mysql 持久化定时任务脚本(tables_mys ...

  2. spring和Quartz的集群(二)

    一:前沿 写完了这两篇才突然想起来,忘记了最关键的东西,那就是在配置文件这里的配置,还有数据库的配置.这是郁闷啊!继续吧! 二:内容配置 我们在集成的时候需要自己配置一个quartz.properti ...

  3. 【淘淘】Quartz之集群利弊

    一.前言: 虽然单个Quartz实例能给予我们很好的任务job调度能力,但它不能满足典型的企业需求,如可伸缩性.高可靠性满足.假如你需要故障转移的能力并能运行日益增多的 Job,Quartz集群势必成 ...

  4. quartz在集群环境下的最终解决方案

    在集群环境下,大家会碰到一直困扰的问题,即多个 APP 下如何用 quartz 协调处理自动化 JOB . 大家想象一下,现在有 A , B , C3 台机器同时作为集群服务器对外统一提供 SERVI ...

  5. 定时组件quartz系列<二>quartz的集群原理

    1.基本信息:      Quartz是一个开源的作业调度框架,它完全由java写成,并设计用于J2Se和J2EE应用中.它提供了巨大的灵活性而不牺牲简单性.你能够用它 来为执行一个作业而创建简单的或 ...

  6. 浅析Quartz的集群配置

    浅析Quartz的集群配置(一) 收藏人:Rozdy     2015-01-13 | 阅:1  转:22    |   来源   |  分享               1 基本信息 摘要:Quar ...

  7. Spring Boot MyBatis 数据库集群访问实现

    Spring Boot MyBatis 数据库集群访问实现 本示例主要介绍了Spring Boot程序方式实现数据库集群访问,读库轮询方式实现负载均衡.阅读本示例前,建议你有AOP编程基础.mybat ...

  8. Redis集群功能预览

    目前Redis Cluster仍处于Beta版本,Redis 3.0将会加入,在此可以先对其主要功能和原理进行一个预览.参考<Redis Cluster - a pragmatic approa ...

  9. 如何解决quartz在集群下出现的资源抢夺现象

    Quartz是一个开源的作业调度框架,它完全由Java写成,并设计用于J2SE和J2EE应用中.它提供了巨大的灵活性而不牺牲简单性.你能够用它来为执行一个作业而创建简单的或复杂的调度,简单的说就是可以 ...

随机推荐

  1. Cacti-安装和使用详解

    Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具.Cacti是通过 snmp get来获取数据,使用 RRDtool绘画图形,而且你完全可以不需要了解RR ...

  2. 033. asp.netWeb用户控件之二将页面转换成web控件和使用Web控件显示热点新闻

    访问Web用户控件的属性 ASP.NET提供的各种服务器控件都有其自身的属性和方法,程序开发人员可以灵活地使用服务器控件中的属性和方法开发程序.在用户控件中,程序开发人员也可以自行定义各种属性和方法, ...

  3. 基于SVG的web页面图形绘制API介绍

    转自:http://blog.csdn.net/jia20003/article/details/9185449 一:什么是SVG SVG是1999由W3C发布的2D图形描述语言,纯基于XML格式的标 ...

  4. winform中dataGridView高度自适应填充完数据的高度

    // winform中dataGridView高度自适应填充完数据的高度,就是dataGridView自身不产生滚动条,自己的高度是根据数据的多少而变动. 在load的时候,数据绑定后,加上如下代码: ...

  5. BigDecimal 的roundMode 舍位模式

    roundMode是指舍位时候的模式,传参数的时候用BigDecimal.ROUND_XXXX_XXX,   有: 以下例子是setScale(0,BigDecimal.ROUND_XXXX_XXX) ...

  6. 实现远程连接ACCESS数据库的方法

    使用了TCP/IP,ADO及(需要安装Microsoft 4.0.).分服务器和客户端两部分,可以多用户同时连接.远程连接Access有很多方法,我以前已经比较详细的回答过(见下面所列的5种方法),我 ...

  7. Python基础篇【第2篇】: Python文件操作

    Python文件操作 在Python中一个文件,就是一个操作对象,通过不同属性即可对文件进行各种操作.Python中提供了许多的内置函数和方法能够对文件进行基本操作. Python对文件的操作概括来说 ...

  8. 神奇的C语言

    当然下面列出来的几点都是C的基础用法,只不过是这些用法可能平时不会被注意.所以很多东西第一次看到的时候,可能会觉得很怪异,但是细细想想就能很好的理解,也就能更好的清楚C语言的一些特性.但是在具体的编码 ...

  9. 关于oracle中to_char和to_date的用法

      一.24小时的形式显示出来要用HH24 select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual; select to_date('200 ...

  10. appframework(jqmobi) 3.0 设置

    $(document).on("panelunload",'#mainPage',function(e){ alert('dddddd'); }); 1.重写 data-load ...