基于xxl-job-2.1.2.Release

直接使用:https://github.com/sunjianbo/xxl-job/tree/2.1.2

doc/db/tables_xxl_job.sql

根据文件内容将其中的mysql语法修改为oracle

这里是我已改好的2.1.2版本对应的oracle文件:下载

/pom.xml

注释

<!-- mysql -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>${mysql-connector-java.version}</version>
</dependency>

替换为

<!-- oracle -->
<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>

根据自己的oracle本版选择对应的jdbc

查看本版SQL: select version from v$instance;

/src/main/resources/application.properties

注释

#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?Unicode=true&characterEncoding=UTF-8
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.datasource.tomcat.validation-query=SELECT 1

替换为

spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:3306:1521/xxl_job
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.tomcat.validation-query=SELECT 1 FROM DUAL

/src/main/resources/mybatis-mapper

  • 查找mybatis-mapper目录下的所有
`

符号,替换为空

  • 查找
AS t

替换为t,搜索AS大写区分或者words

  • 查找
;

符号,替换为空

/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml

将其中

t.`order`

以及

t.order

替换为

t."ORDER"

ORDER必须大写

/src/main/resources/mybatis-mapper/XxlJobLogGlueMapper.xml

去掉select 出的,rownum rnwhere rn改为where rownum

修改后的代码:

<delete id="removeOld" >
   DELETE FROM xxl_job_logglue
   WHERE id NOT in(
      SELECT id FROM(
         SELECT id FROM xxl_job_logglue
         WHERE job_id = #{jobId}
         ORDER BY update_time desc
      ) t1 where rownum  <![CDATA[ <= ]]>  #{limit}
   ) AND job_id = #{jobId}
</delete>

其他Mapper.xml

  • save的自增id修改为oracle格式
  • LIMIT的修改为oracle的rownum
  • 增加jdbcType以防空值报错

注意:

如果加jdbcType的话,XxlJobInfoMapper.xml中有两个属性写的是executorTimeout{executorTimeout}{executorFailRetryCount},注意改成#{}