• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Implement a specific task in Java, unfamiliar with the paradigm, could use feedback/input.

Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My task is to parse a large mssql table into a csv file, to be uploaded elsewhere. This needs to occur on a scheduled basis (daily, but should be configurable), and the task should be able to be executed on the click of a button on a webpage.

It would be non-ideal to install and maintain Tomcat or any other web/application server to run a Java program, because these are not currently available and they probably have unnecessary overhead.

My thought is that I would just write my database querying, csv converting, file uploading, (business logic, etc) in Java, package it up in a jar, and stick it somewhere my Jenkins server can get to (I have access to a Jenkins installation). Then I would just configure a Jenkins job to execute the main method as a shell command on a scheduled basis. And then when the web page button is pushed, I could create a Jenkins job (in php or whatever) to execute the main method a single time.

This seems easy to implement and maintain. Are there any obvious pitfalls here that I'm unaware of? Is this a misuse of Jenkins? Any input on other implementation strategies, or ways to improve the one I propose?

Also, any advice on how to create a csv from a large mssql table, in a time efficicent and memory safe manner, would be greatly appreciated.

Posts: 5167
Netbeans IDE Opera Java
Java Cowboy
Posts: 16084
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea to do this via Jenkins looks like quite a roundabout way to avoid having to run Tomcat.

I would do it with Spring Boot - the program would then just be a single JAR file that you could run with java -jar myprogram.jar somewhere on a server. Spring Boot allows you to have an embedded Tomcat container, so when you start the app it starts a Tomcat that's embedded in the JAR file of the application, so that you can reach it via a browser. It's very easy and convenient, but if you aren't familiar with the Spring Framework and Spring Boot you'd have to learn that first.

Writing a program that does a query and converts the results into a CSV is not very difficult. Just don't write it in a way so that you keep all the result records of the query in memory at once, because then you'll get OutOfMemoryErrors and your program will be slow.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!