• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Real-time database updates display in JSP table

 
John Progton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I apologize if i posted this in the wrong section but I am just looking for a

Basically build a web application that gets updated in realtime from a database.
So for instance when I add a new row of data into the database I want the changes to be reflected immediately in a table on the web UI. UI is just a table that will display data to the user ,who will have no CRUD capability.( The table will be a password protected page or members area of the website a).Additionally the data once updated should call java code which will send an sms via andSMS provider with the update or inserted data. The site site should not poll for the data as it come in randomly and don't want to affect users experience but it is of importance that when the data is updated it is delivered instantly

Basically I just need to know if this is possible specifically for the real time updating and executing of the sms java code and what technologies on the java side must i look into to get this going?

If you have an example you can direct me too this could be wonderful of one that uses a database cause all the current "chat" ones don't


 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will either need to poll for data using AJAX or use websockets to tell the client that new data is available on the server.
 
John Progton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi E Armitage

I have looked for examples that use java+websockets+database(oracle or myslq) but have come short .I have gone thorught the tutorial located at
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.html
but they don't use a database.
Anyone know of a simple exampel where its just updating a table and the results reflect immediately on the webpage?
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You aren't going to get "real-time" or "immediately" response. You need some code which gets the data from the database on a regular basis and displays it. And since the database isn't going to notify you when changes are made, that code is just going to have extract all of the data and display it every time. For this it may be that web sockets are excessively complicated. It might be better to poll via AJAX like E Armitage suggested, or just use an HTML "meta refresh" tag which refreshes the whole page regularly.

As for polling frequency, that depends on how often the database is updated and how long your users can survive without seeing the updated version. For example the screens in the airport which show you the departure times of flights seem to use a polling frequency of about 15 seconds.
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I just remembered that you also wanted to notify people via SMS when the database changed. One way to do that would be to add triggers to the database which would be called after adds, updates, and deletes. However sending an SMS is a long-running process (because it has to access another server) so that sort of thing is frowned on because it slows down the database updates horribly. Alternatively the trigger could just add a record to some other table, and you could have a process somewhere which polled that table and sent out the SMS notifications as required.

Possibly you could have your web application do something like reviewing the database for changes every time it polls the database, if the trigger idea is infeasible. Basically it would have to be keeping a copy of the database in memory to compare against; that might sound bad but you aren't going to have a lot of records so it really isn't. (I say you aren't going to have a lot of records because you're proposing to display the whole thing to users.)
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And finally:

John Progton wrote:I apologize if i posted this in the wrong section but...


Yes, it doesn't seem to have much to do with JSPs at this point in time. We don't really seem to have a forum for "general advice on writing Web applications with reference to databases" so what I'm going to do is move it to the Servlets forum and put a copy in the JDBC forum.
 
John Progton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul

Thank you for the you response. The SMS portion is sorted. Unfortunately with the updates they are random dont have specific time but it is esentila that when tehy are done that there users receives them immediately as it related to forex/stock trading signals so time is essential. I just though Java would have a mechanism to do such as i have already done the same with ASP.NET(signalR)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic