【问题标题】:DatabaseType not found for product name: [Tibero] [duplicate]未找到产品名称的数据库类型:[Tibero] [重复]
【发布时间】:2020-07-30 15:14:29
【问题描述】:

在尝试设置 Spring Boot - Spring Batch 项目时,我遇到了一个错误:

我已经检查了 spring batch 支持的数据库,但 Tibero 不在列表中。

有没有其他方法可以通过指向 Tibero DB 来完成这项工作...

请参考以下错误日志。

Caused by: java.lang.IllegalArgumentException: DatabaseType not found for product name: [Tibero]
    at org.springframework.batch.support.DatabaseType.fromProductName(DatabaseType.java:84) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.batch.support.DatabaseType.fromMetaData(DatabaseType.java:123) ~[spring-batch-infrastructure-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:183) ~[spring-batch-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.createJobRepository(BasicBatchConfigurer.java:129) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.initialize(BasicBatchConfigurer.java:97) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    ... 24 common frames omitted

【问题讨论】:

    标签: java spring-boot maven spring-batch tibero


    【解决方案1】:

    如果您选中 DatabaseType,它将不支持您的数据库 (Tibero)。

    public enum DatabaseType {
    
        DERBY("Apache Derby"),
        DB2("DB2"),
        DB2VSE("DB2VSE"),
        DB2ZOS("DB2ZOS"),
        DB2AS400("DB2AS400"),
        HSQL("HSQL Database Engine"),
        SQLSERVER("Microsoft SQL Server"),
        MYSQL("MySQL"),
        ORACLE("Oracle"),
        POSTGRES("PostgreSQL"),
        SYBASE("Sybase"),
        H2("H2"),
        SQLITE("SQLite");
    }
    

    这些是 Spring Batch 开箱即用支持的数据库。 但是你可以按照documentation注册非标准数据库

    由于 Tibero 与 oracle 完全兼容,您可以创建TiberoBatchConfigurer,如下所示,

    @EnableBatchProcessing
    public class TiberoBatchConfigurer extends DefaultBatchConfigurer {
    
      @Autowired
      private DataSource dataSource;
      @Autowired
      private PlatformTransactionManager transactionManager;
    
      public TiberoBatchConfigurer() {
          super();
      }
    
      public TiberoBatchConfigurer(DataSource dataSource) {
          super(dataSource);
      }
    
      @Override
      protected JobRepository createJobRepository() throws Exception {
        JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
        factory.setDataSource(dataSource);
        factory.setDatabaseType("ORACLE");
        factory.setTransactionManager(transactionManager);
        factory.afterPropertiesSet();
        return factory.getObject();
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-11-09
      • 2020-06-16
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      相关资源
      最近更新 更多