Spring 批处理 - Sybase 尝试在一对非法类型之间进行转换
Spring Batch - Sybase Attempted conversion between an illegal pair of types
我在 运行 使用 sybase 数据库 Spring 批处理作业时遇到异常。该架构是使用 'schema-sybase.sql' 随 Spring 批处理创建的。
Spring-batch版本-spring-batch-core-2.1.7
错误
2015-04-07 09:21:13,138 ERROR
[org.springframework.batch.core.launch.support.CommandLineJobRunner] -
org.springframework.dao.TransientDataAccessResourceException:
PreparedStatementCallback; SQL [SELECT JOB_INSTANCE_ID, JOB_NAME from
BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; JZ006: Caught
IOException: java.io.IOException: JZ0TC: Attempted conversion between
an illegal pair of types.; nested exception is java.sql.SQLException:
JZ006: Caught IOException: java.io.IOException: JZ0TC: Attempted
conversion between an illegal pair of types.
作业配置
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns ="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:import resource="../launch-context.xml"/>
<beans:bean id="helloWorld" class="com.chatar.batch.practice.HelloWorld"
scope="step">
<beans:property name="name" value="#{jobParameters[name]}"/>
</beans:bean>
<step id="helloWorldStep">
<tasklet ref="helloWorld"/>
</step>
<job id="helloWorldJob" incrementer="idIncrementer">
<step id="helloWorldStep1" parent="helloWorldStep"/>
<listeners>
<listener ref="loggingListener"/>
</listeners>
</job>
<beans:bean id="loggingListener" class="com.chatar.batch.practice.listener.JobLoggerListener"/>
<beans:bean id="idIncrementer" class="org.springframework.batch.core.launch.support.RunIdIncrementer"/>
</beans:beans>
实际上,在模式-sybase.sql.
中将 BIGINT 更改为 INTEGER 后它工作正常
看来 sybase 和 JDBC 驱动程序兼容性有问题。
以上方案是用jconn-3.0测试的0.jar
将 JDBC 驱动程序升级到版本 7.0.7 后,它与 BIGINT 一起工作正常 -
jconn-7.0.7.jar
我在 运行 使用 sybase 数据库 Spring 批处理作业时遇到异常。该架构是使用 'schema-sybase.sql' 随 Spring 批处理创建的。
Spring-batch版本-spring-batch-core-2.1.7
错误
2015-04-07 09:21:13,138 ERROR [org.springframework.batch.core.launch.support.CommandLineJobRunner] - org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; JZ006: Caught IOException: java.io.IOException: JZ0TC: Attempted conversion between an illegal pair of types.; nested exception is java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0TC: Attempted conversion between an illegal pair of types.
作业配置
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns ="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:import resource="../launch-context.xml"/>
<beans:bean id="helloWorld" class="com.chatar.batch.practice.HelloWorld"
scope="step">
<beans:property name="name" value="#{jobParameters[name]}"/>
</beans:bean>
<step id="helloWorldStep">
<tasklet ref="helloWorld"/>
</step>
<job id="helloWorldJob" incrementer="idIncrementer">
<step id="helloWorldStep1" parent="helloWorldStep"/>
<listeners>
<listener ref="loggingListener"/>
</listeners>
</job>
<beans:bean id="loggingListener" class="com.chatar.batch.practice.listener.JobLoggerListener"/>
<beans:bean id="idIncrementer" class="org.springframework.batch.core.launch.support.RunIdIncrementer"/>
</beans:beans>
实际上,在模式-sybase.sql.
中将 BIGINT 更改为 INTEGER 后它工作正常看来 sybase 和 JDBC 驱动程序兼容性有问题。
以上方案是用jconn-3.0测试的0.jar
将 JDBC 驱动程序升级到版本 7.0.7 后,它与 BIGINT 一起工作正常 - jconn-7.0.7.jar