有没有人曾将MyBatisBatchItemWriter
与oracle数据库一起使用?
当我将commit-interval设置为2时,会引发协议违规异常。
我使用了ResourcelessTrnasactionManager
和MapJobRepositoryFactoryBean
。
它适用于MySQL。
甚至JdbcBatchItemWriter
也适用于oracle数据库。
只有MyBatisBatchItemWriter
与oracle数据库会导致异常。
异常日志如下。
[2015-01-20 17:27:53.194|DEBUG|o.s.b.core.step.tasklet.TaskletStep:TaskletStep.java:doInTransaction:437] Applying contribution: [StepContribution: read=240, written=0, filtered=0, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]
[2015-01-20 17:27:53.194|DEBUG|o.s.b.s.t.ResourcelessTransactionManager:AbstractPlatformTransactionManager.java:handleExistingTransaction:471] Participating in existing transaction
[2015-01-20 17:27:53.195|DEBUG|o.s.b.core.step.tasklet.TaskletStep:TaskletStep.java:doInTransaction:451] Saving step execution before commit: StepExecution: id=3, version=7, name=putData, status=STARTED, exitStatus=EXECUTING, readCount=3240, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=7, rollbackCount=0, exitDescription=
[2015-01-20 17:27:53.195|DEBUG|o.s.b.s.t.ResourcelessTransactionManager:AbstractPlatformTransactionManager.java:handleExistingTransaction:471] Participating in existing transaction
[2015-01-20 17:27:53.196|DEBUG|org.mybatis.spring.SqlSessionUtils:Slf4jImpl.java:debug:47] Transaction synchronization flushing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@109a2025]
[2015-01-20 17:27:53.196|DEBUG|o.s.b.s.t.ResourcelessTransactionManager:AbstractPlatformTransactionManager.java:processCommit:753] Initiating transaction commit
[2015-01-20 17:27:53.196|DEBUG|o.s.b.s.t.ResourcelessTransactionManager:ResourcelessTransactionManager.java:doCommit:37] Committing resourceless transaction on [org.springframework.batch.support.transaction.ResourcelessTransactionManager$ResourcelessTransaction@288ca5f0]
[2015-01-20 17:27:53.196|DEBUG|org.mybatis.spring.SqlSessionUtils:Slf4jImpl.java:debug:47] Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@109a2025]
[2015-01-20 17:27:53.196|DEBUG|org.mybatis.spring.SqlSessionUtils:Slf4jImpl.java:debug:47] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@109a2025]
[2015-01-20 17:27:53.196|DEBUG|o.s.jdbc.datasource.DataSourceUtils:DataSourceUtils.java:doReleaseConnection:327] Returning JDBC Connection to DataSource
[2015-01-20 17:27:53.197|ERROR|jdbc.sqltiming:Slf4jSpyLogDelegator.java:exceptionOccured:116] 7. Connection.close()
java.sql.SQLException: protocol violation
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:459) ~[ojdbc5-11.2.0.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191) ~[ojdbc5-11.2.0.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4C7Ocommoncall.doOLOGOFF(T4C7Ocommoncall.java:61) ~[ojdbc5-11.2.0.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:498) ~[ojdbc5-11.2.0.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:3915) ~[ojdbc5-11.2.0.2.0.jar:11.2.0.2.0]
at net.sf.log4jdbc.ConnectionSpy.close(ConnectionSpy.java:896) ~[log4jdbc-remix-0.2.7.jar:na]
at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:341) [spring-jdbc-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) [spring-jdbc-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:294) [spring-jdbc-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils$ConnectionSynchronization.afterCompletion(DataSourceUtils.java:476) [spring-jdbc-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168) [spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:994) [spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:969) [spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:800) [spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724) [spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:148) [spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:77) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368) [spring-batch-infrastructure-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) [spring-batch-infrastructure-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144) [spring-batch-infrastructure-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:198) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:165) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:304) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) [spring-core-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128) [spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
at com.skplanet.storeplatform.batch.sac.common.main.BasicBatchRunnerMain.run(BasicBatchRunnerMain.java:60) [classes/:na]
at com.skplanet.storeplatform.batch.sac.common.main.BasicBatchRunnerMain.main(BasicBatchRunnerMain.java:45) [classes/:na]
[2015-01-20 17:27:53.197|DEBUG|o.s.jdbc.datasource.DataSourceUtils:DataSourceUtils.java:releaseConnection:297] Could not close JDBC Connection
答案 0 :(得分:0)
这是mybatis错误。现在,在映射器文件中将mybatis标记从<insert>
更改为<update>
。