Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6774611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:48:29+00:00 2026-05-26T15:48:29+00:00

I want to use Spring Batch and Spring Integration to import data from database

  • 0

I want to use Spring Batch and Spring Integration to import data from database and write them into a file and ftp them to a remote server.

But I guess my problem is I don’t want to create Domain Object for my table. My queries are random and I want something that just reads the data and writes it to files and transfer.

Can I use Spring Batch and Integration without creating respective domain objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:48:30+00:00Added an answer on May 26, 2026 at 3:48 pm

    Absolutely. You can use either of the JDBC ItemReaders or the JPA ItemReader with a ColumnMapRowMapper to retrieve a Map of the result set. You can use the FlatFileItemWriter pretty simply to output the data in whatever format you like (delimited being very easy with the provided classes; fixed width means writing one class to translate the Map to your fixed width string).

    I do this pretty often with Spring Batch and it’s pretty much just a matter of wiring things up.

    Aside from defining a resource, data source, and providing the SQL, this (untested) configuration would pretty much do exactly what you’re asking:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/batch"
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
            http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
    
        <job-repository id="jobRepository"
            data-source="jobDataSource"/>
    
        <beans:bean id="transactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
            p:dataSource-ref="jobDataSource" />
    
        <beans:bean id="extractReader" scope="step"
            class="org.springframework.batch.item.database.JdbcCursorItemReader">
            <beans:property name="dataSource" ref="appDataSource" />
            <beans:property name="rowMapper">
                <beans:bean
                    class="org.springframework.jdbc.core.ColumnMapRowMapper" />
            </beans:property>
            <beans:property name="sql">
                <beans:value>
                    . . .
                </beans:value>
            </beans:property>
        </beans:bean>
        <beans:bean id="extractWriter"
            class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
            <beans:property name="resource" ref="fileResource" />
            <beans:property name="lineAggregator">
                <beans:bean
                    class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
                    <beans:property name="delimiter">
                        <util:constant
                            static-field="org.springframework.batch.item.file.transform.DelimitedLineTokenizer.DELIMITER_TAB" />
                    </beans:property>
                    <beans:property name="fieldExtractor">
                        <beans:bean
                            class="org.springframework.batch.item.file.transform.PassThroughFieldExtractor" />
                    </beans:property>
                </beans:bean>
            </beans:property>
        </beans:bean>
    
        <job id="extractJob" restartable="true">
            <step id="extractStep" >
                <tasklet>
                    <chunk reader="extractReader" writer="extractWriter"
                        commit-interval="100" />
                </tasklet>
            </step>
        </job>
    
    </beans:beans>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use Powershell in order to call a batch file on remote
I came from the Spring camp , I don't want to use Spring ,
I'm a newbie on Spring-Batch and I want to use it to batch some
I want to search a file in the current directory from which the batch
I've recently started upgrading some applications to use Spring Webflow 2, and I want
I want to use @PreAuthorize annotation on service methods with Spring Security. One of
I want to use both ContextLoaderListener (so that I can pass Spring Beans to
I'm migrating a Spring MVC controller to use the newer style annotations, and want
I want to create a web app that will use wicket, hibernate and spring
I want to use Spring-Tiles intergration. Here you can see how my app looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.