Your last description helps. Sounds like you have two events to handle:
1) New message added to database. How will you know when this happens? If the message comes in over some program-to-program protocol like JMS or XML over HTTP and you update the database then you'll have code that is executed when they come in. If your other message sources just write to the database I'm not sure how you'll know a new message has been written.
2) Forwarding the message to the user. If each message goes to only one user I might look at the applet with server socket again. The server could open connection, send message, close connection in a couple seconds.