使用弹簧批红移DATABSE配置数据源时,遇到了异常

使用弹簧批红移DATABSE配置数据源时,遇到了异常

问题描述:

我的数据源配置为:使用弹簧批红移DATABSE配置数据源时,遇到了异常

dataSource.setUrl("jdbc:redshift://spx....redshift.amazonaws.com:5439/spx"); 
dataSource.setUsername("spx"); 
dataSource.setPassword("*****"); 

获取例外: -

2017-10-06 15:58:58.670 INFO 5560 --- [   main] .s.b.c.e.j.JettyEmbeddedServletContainer : Jetty started on port(s) 8080 (http/1.1) 
2017-10-06 15:58:58.670 INFO 5560 --- [   main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: [] 
2017-10-06 15:58:58.670 INFO 5560 --- [   main] o.s.b.c.r.s.JobRepositoryFactoryBean  : No database type set, using meta data indicating: POSTGRES 
2017-10-06 15:58:58.749 INFO 5560 --- [   main] o.s.b.c.l.support.SimpleJobLauncher  : No TaskExecutor has been set, defaulting to synchronous executor. 

2017年10月6日15:58:59.796 INFO 5560 --- [main] utoConfigurationReportLoggingInitializer:

启动ApplicationContext时出错。要显示自动配置报告,请启用'debug'重新运行您的应用程序。 2017年10月6日15:58:59.802 ERROR 5560 --- [主] osboot.SpringApplication:应用程序启动失败

java.lang.IllegalStateException: Failed to execute CommandLineRunner 
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:735) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] 
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:716) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] 
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:304) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] 
at com.spring.batch.redshift.example.BatchApp.main(BatchApp.java:22) [bin/:na] 
Caused by: org.springframework.dao.DataAccessResourceFailureException: Could not obtain sequence value; nested exception is java.sql.SQLException: [Amazon](500310) Invalid operation: "batch_job_seq" is not a sequence; 
at org.springframework.jdbc.support.incrementer.AbstractSequenceMaxValueIncrementer.getNextKey(AbstractSequenceMaxValueIncrementer.java:78) ~[spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE] 
at org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer.nextLongValue(AbstractDataFieldMaxValueIncrementer.java:128) ~[spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE] 
at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:108) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE] 
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:135) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE] 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101] 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101] 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101] 
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101] 



Caused by: java.sql.SQLException: [Amazon](500310) Invalid operation: "batch_job_seq" is not a sequence; 
at com.amazon.redshift.client.messages.inbound.ErrorResponse.toErrorException(Unknown Source) ~[na:na] 

这个数据源是没有弹簧一批做工精细

在我的情况是,jobRepository databaseType =必须与dataSource =脚本相匹配

+0

是否支持redshift + spring批处理。因为我们无法在redshift中创建序列,但是每当启动应用程序时,spring批次都在搜索数据库中的序列 –

+0

在您的情况下,您将必须找到哪个数据库最接近红移,甚至更新现有脚本以便相应地进行红移,是如此多的准备在spring-core库中使用org/springframework/batch/core/schema - *。sql中的脚本。 – kisna

+0

DB最接近红移的是postgresql。但在postgresql中,我们可以创建后缀。 –