Take the 2-minute tour ×

I'm starting a new project. It consists of:

  • Java desktop application downloadable from the internet with a client database.
  • PHP website on the internet with a server database.

The user who downloaded the app will use it to add items (not important what are they now) to the local database offline. When/If he is online, the item will be added to the server database so other connected users (through the desktop app or through the website) will see it. I googled the issue and found it's more complected than I guess. One of the solution is to use some ready tools like SymmetricDS and Daffodil to gain in term of security, performance and scalability, but they're difficult to configure and install in both client and server side, and need the access to command prompt which requires me to pass to a dedicated host (well, that is not a real problem). Also, all what I want is just what I've described, not all what these tools actually provide.

  • Can I achieve that by myself within my Java application and maybe with the help of the web server PHP?

I'm using MySQL for the info.

Edit: what really matters is to send items to the server database. Reading it can be less tricky using RSS Feed reading, for example.

share|improve this question
You should be able to achieve what you want with SymmetricDS (although you may indeed need a server where you can run your own Java application). When you say it's difficult to configure, are you concerned about how your users may have to deal with it (in which case you might be able to embed it in your own application) or more about the overall complexity that you may have to administer? –  Bruno Oct 3 '12 at 12:08
You're actually right. I just asked about simpler ways according to my particular case, and that seems worked. I think I found a shorter way, using a PHP page; I send data to the URL and POST it through HTTP. PHP page will receive the data and save it to the database. Do you have comments over this way? I know it's a partial solution, but I think things got clearer know. –  Nadjib Mami Oct 3 '12 at 12:22

3 Answers 3

up vote 1 down vote accepted

Basically, you can use HTTP/HTTPS API. When a user online, send items to your php file and mark the items "sended" at local database. But you have to control edited or deleted statuses. So, yes that is much complicated but a solution.

share|improve this answer
Looks interesting tersakyan. I need to know now how to send information to the URL through POST request in HTTP protocol using Java. Thanks. –  Nadjib Mami Oct 3 '12 at 12:04
Thanks tersakyan, your reply was very helpful. –  Nadjib Mami Oct 3 '12 at 14:43
A good snippet of code is found here: exampledepot.com/egs/java.net/post.html –  Nadjib Mami Oct 3 '12 at 20:12

Well the easiest solution that comes to my mind would be to save for each item a last edit date (on the server as well as on the client). Additionaly you have to keep track when a client got his last update from the server.

So whenever a client goes online the server sends him all updates.

But for that you have to make sure that the time on the client and the server are the same, and it doesn't solve the problem what happens if two clients edit the same item.

share|improve this answer
Thanks Icewind. The item can't be modified by more than one (its owner), but I don't see where is the solution. –  Nadjib Mami Oct 3 '12 at 10:41

CouchDB solves the distributed synchronization problem very nicely, but it is a NoSQL DB. Depending on what your application should do, using it would boil down to using instances of CouchDB both locally inside very application, and on the central server.

You'd have to deal with conflicts nevertheless. The only thing CouchDB will support you with is easier detection of conflicts, and the data of both conflicting edits, so your application can work it out either automatically, or with user help.

On the other hand, generatin a unique id on the central server can be as easy as adding the creating user's id to each item id.

share|improve this answer

Your Answer


