Search code examples
javamysqljtablereal-timetablemodel

JTable + MySQL "Realtime Feeling"


I have a JTable that get's populated with data from a MySQL Table, but there are multiple Clients updating and inserting to the Database at once. My Goal is to provide some kind of near realtime experience for the Table. I thought of just updating the TableModel every let's say 5 seconds, but with over 1000 rows that doesn't really make sense. Could someone explain me how the general approach to something like this looks or which techniques i should be using,

Thanks in advance,

Stefan


Solution

  • You'd need to go for a 3 tier architecture:

    Between swing clients and MySql database put an application server.

    The clients will not connect directly to the database, instead they'll connect to the application server which will provide higher level APIs (e.g. business logic methods) to get the data from the DB.

    As for data refresh in clients, you could use something like JMS to push events to the clients when data changes.

    If you don't have control of the other clients that change the data you'll have to use some kind of polling.