Question: I have a scenario where my Java program has to continuously communicate with the database table, for example my Java program has to get the data of my table when new rows are added to it at runtime. There should be continuous communication between my program and database.

If the table has 10 rows initially and 2 rows are added by the user, it must detect this and return the rows.

Answer: 
With HSQLDB, this is supported without continuous polling.

HSQLDB TRIGGERs support synchronous or asynchronous notifications to be sent by the trigger event. The target may be the user's app or any other app.

See <http://hsqldb.org/doc/2.0/guide/triggers-chapt.html>
This is not possible. You'll have to regularly poll the database in order to detect changes.