This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Servlet Listener will not pool any database table, to get info like any new record inserted or deleted... I would suggest you that in Database (table trigger) we can write code to add new record details into a file.
Joined: Dec 23, 2008
The example I gave is not the exact implementation in the application.
The application has a component in the home page that reads the file that I am writing to. This component then (after some business logic) reads the file and displays the data in it.
Hope I have made myself clear.
Thanks for giving your idea. Writing a trigger will definitely be in the direction to solve the problem. But it is a huge overhead on the application.
Is there any other alternative to solve this problem?
Matt Thomassan wrote:Is there any other alternative to solve this problem?
What problem? You still haven't described the purpose of this file. I would say the "solution" would be to get rid of the file and read from the database if you don't have a reason for the file existing.
Joined: Dec 23, 2008
The following is the purpose of the file:
Home page has a flash component that reads data from xml file. This xml file is required to be updated when some database modifications happen.
It may be too late in the day to suggest this but any reason you didn't just query the database form your Flash application? This would be a far easier way of doing this.
The only guarenteed way to push data out to the file is a database trigger. If your database supports it you could use Java to write such a trigger for update, insert and delete events. If it doesn't support Java some databases have their own mechanisms for doing this sort of thing. Not very nice adding the overhead of this extra IO work for every mutation on the table though. And if you ever deploy your application in a clustered environment you are stuffed.
Another alternative is to poll the database from your Java code using something like a timer task and update the file accordingly. This has the advantage of not burdening your database with the file creation, but has the disadvantage that your data is always out of date (though you have engineered that problem into your application anyway by using a file as an intermediary).