• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Read a flat file then put it in java objects with array list and then store in a DB

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a requirement to read a flat file then put in java objects with array list and then store in database. Please provide a best solution and design pattern to follow.

Thanks
Suresh
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are loads of tutorials on-line for how to read a flat file. As for "put in java objects with array list and then store in database" that really depends on what data is on the file, how it is formatted etc and what exactly you mean by "java objects with array list".
 
suresh dhanapal
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tony,
First I want to map the school objects into list and then list to DB
public class SchoolsDataSet {


private long schoolBedsCode;
private long schoolPrevSEDCode;
private String schoolName;

}
Thanks
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I see you have a POJO that maps to the database table. That's good.

The simplest to start with is probably using the data access object pattern to save data into the database.

Then you will need another method or class to actually read the file content. As Tony mentioned, there are lots of ways to read a file.

Once the data is read, trigger the POJO's save method.
 
suresh dhanapal
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks , I found solution
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic