Announcement Announcement Module
Collapse
No announcement yet.
Database to flatfile Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Database to flatfile

    i have been trying al ot to copy content from database to a flatfile.Iam able to retreive but doesn copy to a file.i have no errors too,plz help.

  • #2
    You'll probably want to use the FlatFileItemWriter:
    http://static.springframework.org/sp...s.html#d0e4650

    Without any details, it's hard to provide more guidance than that...

    Comment


    • #3
      hi there..
      thanks for ur reply....
      i am reading from a database and writing to a flatfile....i have followed the trade job example given in the samples......but i am not able to write it.i have no errors too..it says successfull...but doesn write to the file.....i donno whr i am going wrong..its reading from db..i can retrieve the values too.....u have any idea if there is anyother way to read from db and write to flatfile...

      Comment


      • #4
        hi..
        my problem is solved...the problem was with the path.Now i have a scenario of reading data from db and writing it to multiple files on the fly.The scenario may be like taking data from the file at the end of day...so data may vary day to day..may be 10, 15..50 ,anythng...so not sure of how many writers to use.What cud be the best solution...can u plz help me?

        Comment


        • #5
          What determines how many files and which records should go to which files?

          Comment


          • #6
            hi dan,

            its like read data from table and write each record to a diff file....the number of records in the table may differ any time...hope you got the scenario....
            Last edited by sbdev; Mar 4th, 2009, 11:53 PM. Reason: spelling

            Comment


            • #7
              hi
              let me explain u the scenario in detail...
              there is table which has an 'id' coloumn which is unique.
              now the data must be read and written to a file on the basis of the id.
              that is each row will be written in a new file.My doubt is where does my logic go.in the writer or reader?
              thnk u

              Comment


              • #8
                Your reader will read every record from that table. You should create a custom writer that creates a new file for each item that it receives.

                Comment


                • #9
                  hi...
                  that is what i was trying to do but i am stuck up with the items.How do i limit them to one row in the item.there is no such property in the mapper to say to read or return a particular line...can u help me with this....

                  Comment


                  • #10
                    I don't really understand your question. Each item returned from the ItemReader will be passed to the ItemWriter which will create a file and write the item.

                    By the way, what version of Spring Batch are you using?

                    Comment


                    • #11
                      hi
                      i have a reader which reads all data from table and puts in an object.Now when it comes to writing..the scenario is like....each row from the table is wriiteen to diff files...but my object is containing all the data...so i donno how to limit each line to each file.i tht i need diff items but if it was each colomn in a file tht wud work...when it comes to each row in diff file...i m stuck up....hope i was able to explain...i am using 1.1.4

                      Comment


                      • #12
                        Why is your reader putting all of the data in an object? The framework is designed to pass each record to the writer. What ItemReader implementation are you using? Since you're reading from the database, you'd most likely want the JdbcCursorItemReader.

                        Also, proper spelling, punctuation, and spacing would make your posts much easier to read.

                        Comment


                        • #13
                          hi
                          ya i am using JdbcCursorItemReader.When i am reading from table now...u mean i should hav different reader with diff sql statement and diff mappers to a common writer..which writes to diff files...?
                          sorry bout grammer...

                          Comment


                          • #14
                            1.i have a table with two rows...
                            2.used a JdbcCursorItemReader to read the two rows....
                            3.used a rowmapper to map.
                            4.a writer which writes to a file.

                            with the above sequence i am able to write both the rows to the file.
                            what i want exactly is to write each row to a different file.
                            so i can use line mapper to map to each line but how do i specify the line number?
                            do i write a custom mapper and a dao which will call this mapper with the line number..?
                            i feel that wud make it very complex...so wanted some simple solution....
                            hope ur getting me....

                            Comment


                            • #15
                              My problem is solved..i am able to do what i wanted to thnq.....

                              Comment

                              Working...
                              X