spring-boot-oracle spring-batch

Install/Configure Oracle express
  1. Oracle xe installer for linux (I don't care if you're running linux or not, this guy is going in a VM): http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
  1. sqlplus /nolog
  2. connect sys as sysdba
Oracle JDBC Driver shenanigans
  1. Download the JDBC driver: http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
  2. Here's where things get interesting. Apparently gradle can't load this jar from a flatFile repository. So the workaround is to create a local maven repository and load this 1 jar into it.
  3. cd to the directory where the ojdbc jar is located
  4. mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar
  5. In the above command make sure to adjust the file, artifactId, and version to match the driver you downloaded.

https://github.com/shawn-mcginty/spring-boot-oracle-example

How to copy from CSV file to the database. 

https://github.com/wbotelhos/spring-batch-flat-file-database

通过 spring boot 启动spring batch读取csv文件并使用hibernate将插入MySQL数据库

 https://github.com/zyongjava/spring-batch

spring-batch-jpa

This is an example project that contains everything needed to use Spring Batch 3 to read from a database via JPA and write to a database via JPA. There are also tests.

There were two blog entries associated with this project.

Blogs

Spring Batch – reading and writing JPA

This is a simple Spring Batch project. This implementation will read from a database table and write to a database table via JPA.

http://javaninja.net/2016/02/spring-batch-reading-and-writing-jpa/

Spring Batch JPA Testing with Transactions

This blog goes over all of the testing options I was able to discover for Spring Batch with JPA.

http://javaninja.net/2016/02/spring-batch-jpa-testing-with-transactions/

https://github.com/sheltonn/spring-batch-jpa

 

Spring Boot Spring Batch JPA PostGreSQL

org.springframework.batch.item.database.JpaItemWriter

    /**
     * Nothing special here a simple JpaItemWriter
     * @return
     */
    @Bean
    public ItemWriter<Person> writer() {
        JpaItemWriter writer = new JpaItemWriter<Person>();
        writer.setEntityManagerFactory(entityManagerFactory().getObject());

        return writer;
    }

 

    /**
     * As data source we use an external database
     *
     * @return
     */

    @Bean
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName(databaseDriver);
        dataSource.setUrl(databaseUrl);
        dataSource.setUsername(databaseUsername);
        dataSource.setPassword(databasePassword);
        return dataSource;
    }


    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

        LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
        lef.setPackagesToScan("com.iqmsoft.spring.batch");
        lef.setDataSource(dataSource());
        lef.setJpaVendorAdapter(jpaVendorAdapter());
        lef.setJpaProperties(new Properties());
        return lef;
    }


    @Bean
    public JpaVendorAdapter jpaVendorAdapter() {
        HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
        jpaVendorAdapter.setDatabase(Database.POSTGRESQL);
        jpaVendorAdapter.setGenerateDdl(true);
        jpaVendorAdapter.setShowSql(false);

        jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.PostgreSQLDialect");
        return jpaVendorAdapter;
    }

 



 https://github.com/Murugar/SpringBootBatchJPA

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值