Reputation: 23
I'm working on a project and am a bit stuck for the best way to approach it, so i'll highlight it below;
The Project: I want to create a program that calculates data and then uploads this to a MySQL table approximately every 5 seconds. There would be about 40 pieces of data all being updated at the same time. I have a couple of years worth of Java experience, and so wanted to simply create a program in Java that would compute these values, which would then update the MySQL tables
The Problem: I need to use a form of technology that is powerful enough to run the algorithm to perform the calculation, then update the values of a MySQL table every 5 seconds. My ideal approach would definitely be to use Java if possible (due to my experience). If this is possible, is it possible to have a Java program running in the background on a server? If so, is there any requirement to the server? Ideally I'd like the processing to be server sided, as the results would then be updated by the time the client logs back in.
If you can offer any advice into this , thank you incredibly much :) If you need more information, please ask!
Upvotes: 0
Views: 128
Reputation: 358
You can run "any" process on the background.
All you need is:
1. JVM installed on the server
2. JDBC driver for SQL Server
It should be very easy to implement.
Just google for "JDBC example".
You can write a simple java program:
class MyClass {
public static void main(String[] args) throws InterruptedException {
do {
Thread.sleep(5000);
writeToSQL();
} while(true);
}
static void writeToSQL() {
System.out.println("writing to SQL");
}
}
Upvotes: 0
Reputation: 2883
Yes, it is possible. You will probably need virtual machine hosting (shared hosting is not enough). AWS from Amazon could be used. It is just a Linux machine with root access, so you can do what ever your want.
You may use JavaServiceWrapper
(http://wrapper.tanukisoftware.com/doc/english/download.jsp) it will help you with running java as background daemon.
This daemon may monitor some input (MySQL tables for example), calculate data and send it back.
If calculation process is complex enough, you may want to use some EIP tools like Apache Camel or Spring Intergration, but I am almost sure simple background daemon is enough.
Upvotes: 1