OK so here is the scenario.
I have a local Java application running on a desktop. Users/clients need to check in to this (by going through required steps) either every day, every other day, weekly, biweekly, monthly, etc (admin-defined for each user).
In my web application, an admin would add the user and the schedule they need to check in to. If the user does not check in by their required time, then the admin would be alerted of this person and he can complete other actions from there.
How should I go about doing this and should it be done through MySQL or Java? I thought about scheduling events in MySQL but that could not be admin-defined on the web app. I'm not sure what else to do for this.
MySQL is good for storing state. Maintaining records of when they checked in is good, and you can write a script that sees who hasn't checked in when they needed to and alerts the admins. The Java application then just has to update the MySQL record with the current time everytime they check in.
Related
For a VAADIN Java Application running on Tomcat7 with Neo4j Database System, i need to create a routine that checks all users everyday at 12AM, and sends email to all of the users who have been returned by my request (the request is ready, and works well).
The problem is here:
I don't know how to start one of my class each day at 12 AM in the application, i already tried Quartz and Java.ejb.Schedule but none of them have worked, Quartz creates me a memory error and only starts the class once, and ajb is simply not working (no loop at all).
Is there an easier way to achieve this? i just need to start my class each day, even if no users are on the application.
I am trying to develop a mechanism for Sync data with app & server, like Google Drive/Dropbox for one of my android based application where data are stored locally on device and I would like to sync data with server.
Ways thought -
1) Observer which looks for change and call web service
2) Background service which runs in background and check for changes
3) Set Alarm which checks at particular time and sync all the data with server
I have not started to which option to go with, I would like to get experts view on this and like to get some guidance so that I can achieve the sync mechanism in best possible way for my app.
All suggestion are welcome.
Thinking on same line as you have been,the aim should be to achieve a balance between the number of times the server is queried for same set of information AND the data consistency.
for this, I would fire a GCM message from my server to the device for which the data on the server has changed, I would maintain a count for these Update Messages(No Notification genereated). If this count Exceeds the minimum-threshold-count-value, I would immediately call for an UPDATE. Or otherwise, if this count still is less than the threshold-count-value, for a certain period, that I would call the threshold-waiting-period, then too I call for an UPDATE.
The UPDATE would be using Sync Adapters and Services. This link explains its basics.
Hope this prooves to be helpful!
...so that I can achieve the sync mechanism in best possible way for my app
Well, the BEST mechanism depends completely on what kind of application, you are developing. Also, your option 1 and 2 seems very similar to me except few implementation changes. However, how frequently your device data is changing, that also matters a lot. If you have authentication mechanism, you can configure sync up, at the time, whenever you login to your app. Like in case of confidential data, sync up should happen immediately.
If data is managed well based on authentication and authorization based on user roles or so, you also need to take care of synchronization among them. For example, one user has updated an entity which is not yet sync and another user tries to update the same, then first user will see his changes are not synced or has been lost.
The best way (means having least drawbacks) to do this would be sync up trigger at a particular interval of time OR at every login time. (still as I said, depends on your app).
Hope this would clear some or all of your doubts.
I'm developing a Java web application. The scenario is described below:
Many users submit their status and they can see others' statuses as well. It looks like a kind of social network.
Their statuses have a period of time to display, after this period, their statuses in database will be deleted.
At the time their statuses are deleted, send a notification to all users to request an update (the deleted statuses have to be vanished in realtime!)
I've tried to do that automatically by a thread in the Java web application. However, I'm stuck at some problems:
+Is it possible to manage database like that? I've thought of database event, but when a record is deleted, I will not be noticed.
+I'm using web socket to make the application work in realtime. If a person update a new status or change it, it's possible to send an update notification to all of the users by using web socket. But when the changes come from database, I don't know how to send a notification like that.
Can you give me some ideas? Thank you in advanced!
You can use DelayQueue to store each item to be removed at a specified delay,and when you are removing the item,remove the record in database and send a notify to browser.
Here is the tutorial how to use a timer service in a Java EE 6 application:
http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html
If you need the statuses to be deleted even if your program crashes, then I recommend that you use quartz - this way if your program crashes then quartz will update the database when you re-load your program. If your program doesn't need to be this robust then use a DelayQueue instead.
I am want to do registration in my app. So i have made all requests to my web service.
I now when user is registered.
Now i need to save somewhere that he is registered that don't give him registration form again.
How to do this ?
Do i need to save somewhere in my sqlite database and every time when app lunches check if he is registered user. Or maybe in app settings i could save this information.
I am new to developing android app and i am searching for the right way.
Thanks all for help.
You could save that with SharedPreferences. Check the link for sample code.
http://developer.android.com/guide/topics/data/data-storage.html#pref.
This data will be removed if the users uninstalls the app or clears all data from system menu.
Edit: If you really want to remember preferences across installs you should try Backup API. http://developer.android.com/guide/topics/data/backup.html
The best solution is to use Android's Account Manager to handle user account. This aproach is the most secure (credentials are not exposed), however it has two drawbacks:
It's a little bit complocated to set up
It requires at least API version 5
Once the user registered you can save in your sqlite database and you have to check for each time when your application launches. But if the user uninstalled the application and tried to reinstall it ll ask for registration again.. In order to avoid this you have to store the information like the device id and the registered details in some servers and also in sqlite database and have to check when the application launches...
I have an Apache Derby database running (in networked mode) inside a java swing application, I connect to it through direct JDBC calls via a java client application.
This is all very good and works great however I know have an additional requirement to implement concurrent licenses for this client/server application.
Ideally a user with a single user license should be able to have 1 client app running on a laptop and also a second client app running on a desktop and be able to connect to the server from both.
I don't have the luxury of a web server so I am wondering if my only option is to use the "maxthreads" runtime property in Derby and essentially force the user to have to log off the laptop say if they want to then use the app from their desktop.
If I leave the timeslice property to 0 then will a call to getConnection timeout so that I can display a message to the user explaining that they need to disconnect one of the client apps.
Are connection threads a reliable way of doing this?
Am I missing another solution?
If I understand the question correctly, you have user-locked licenses and want to prevent a single user with a single license from accessing the "server" from more than one instance of the client at a time. Your "server" is simply a database and you don't want to create an application layer on the server side.
I don't really like your initial suggestion of using the thread pool and connection timeout to enforce licensing constraints because both of those things are used for other purposes.
Instead, to solve this I might consider requiring the user to enter their license number into the GUI the first time they use it. This can be saved in the user's home directory for subsequent starts of the GUI. The same would happen if they start the GUI for the first time on another machine. Then, for each transaction the GUI makes with the database, it would first update a licenses table or similar to indicate the user's license is currently taking part in a transaction. Wherever the same license is already in the table, marked as active, or similar, the GUI would reject the transaction and display to the user their license is already in use by another client.
If you like this idea, think it through farther than I have. I can see some errors in logic locking users out permanently :-)
It seems like you want to make the action of "logging in" and "logging out" of the database explicit, so perhaps you may want to have a special table in the database where your application writes a record when you log in or out.
Then your application can query that table to find out if other copies of the application are currently logged in.
You might want to include additional fields in the table to track the date/time when you logged in/out, the hostname and IP address of the client which performed the login/logout, etc.