Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
suresh dhanapal
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • 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
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks , I found solution
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!