This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes to listen database table by java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

to listen database table by java

Jyoti Sharma
Greenhorn

Joined: Apr 23, 2010
Posts: 9
Hi,

I need to watch a table i.e., whenever there is insert in a table my java code will do some actions. For this I am planning to use while(true) loop. In this infinite loop I will select data from table. If there is some new insert in table, I will perform my functions and will continue to do this whenever there is a new insert in table.

My code will run forever and there will be scheduled shutdown in a week and will be restarted in 5 - 10 minutes.

Is it a right approach to use while(true) ?
Any other way to listen database table ?

Note: database is Teradata (RDBMS) and not Oracle
Thanks,
Jyoti
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

That is definitely not a right approach.

Check out with the hibernate.


SCJP 5, SCWCD 5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41060
    
  43
Duplicate of http://www.coderanch.com/t/499406/Performance/java/while-true. Closing this topic.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to listen database table by java
 
Similar Threads
Could not parse mapping document from resource PojoTestTable.hbm.xml
Ajax Real Time Example
need to use while(true)
TCP/IP Connection lost
AUTO_ACK for JMS P2P