• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create stand alone java application

 
Don Martino
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have always coded web applications using jsp's and depending what is selected from the web page then methods in java classes are called and processed, but always returning to the jsp.
Now, I want to write a java program that simply reads a table, selecting off certain records, using data from these records to populate fields in output records and write the formatted output records to a flat file.
After all records are processed I need to hand off the flat file using NDM which will transmit the file to a server where another application will process these records.

A cron job will automatically run daily which will kick off my process. Will this cron job execute my stand alone java program containing a main method?

My processing consists of reading one record from table, performing a few calculations using data from record, populating the output record and writing this record to a flat file.

Should I include the connection and table processing in this same class or call a method in a separate class that performs the table stuff?
 
Don Martino
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me simplify my question;

I want to read records from a table, format and write new records to output flat file.

Do I simply write one java class that does it all or do I write another java class that performs the database processing?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably better to have a class which handles the transmission to the database and back, and other classes which handle input and output.
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I would do it, I would separate the classes to talk to the db, to process the data and to talk to the files.

Regards
 
syruss kumar
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its better to divide your operation into steps communicating to database,format it as your required format and send back to the server. Now in simple way you can create a class for each steps and make them to communicate with each other by passing the required data.

If you want to automate your process you can go for scheduler and timertask in java .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic