0

Basically, I want to get the current database state in every client each time database state changes.

Let's suppose I have two computers, each one is running the same Java application, and PostgreSQL in a server.

When a client is connected to my server and does an operation that persists an object (let's say Person) into the database, the persisted object fields (let's say ID, name, surname) appear in the client's main window that executed the operation, but named fields doesn't appear in the other client's window.

My two clients can connect to my server perfectly.

If you think some piece of code could help, just let me know.

By the way, I've heard about something called "Server push", can that help with what I want to do?

Albert.

PS: Sorry for mistakes, my English isn't very good :P

Neniel
  • 163
  • 16

1 Answers1

0

You'll want to make use of postgresql's LISTEN/NOTIFY capability.

Here's an example using JDBC (http://wiki.postgresql.org/wiki/PgNotificationPoller)

Likewise, How to make a database listener with java? has some good more Hibernate-y resources already provided.

Essentially, at the highest level, you'll use some background thread to poll the server to see if there are any NOTIFY events for the channel for which you want updates. If an update is present, you can update your GUI accordingly.

Community
  • 1
  • 1
Aaron Hammond
  • 617
  • 4
  • 9