Spring Batch - Unable to create metadata tables on Postgres and load actual data to mysql

后端 未结 2 1906
梦谈多话
梦谈多话 2020-12-18 17:59

I am developing Spring Boot v2.2.6.RELEASE + Spring Batch. In this example, I am looking to read csv file, load the data into mysql and spring batch metadata ta

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-18 18:19

    Thanks Abinash for great help. I simply reverse Primary and Secondary. It worked.

    # Datasource - Secondary
    spring.datasource.driver-class-name=org.postgresql.Driver
    spring.datasource.url=jdbc:postgresql://localhost:5432/program?currentSchema=BATCH
    spring.datasource.username=postgres
    spring.datasource.password=admin
    spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
    spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
    
    spring.jpa.hibernate.ddl-auto=create
    spring.jpa.show-sql=true
    spring.jpa.properties.hibernate.format_sql=true
    
    # Postgres - Primary
    spring.hello.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.hello.datasource.url=jdbc:mysql://localhost:3306/test
    spring.hello.datasource.username=root
    spring.hello.datasource.password=root
    
    #spring.batch.table-prefix=batchmetadata.BATCH_
    spring.batch.initialize-schema=always
    spring.batch.job.enabled=false
    
    spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
    

    Also, using below worked.

    writer.setSql("INSERT INTO \"BATCH\".customer VALUES (:id, :firstName, :lastName, :birthdate)");
    

提交回复
热议问题