File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Database Message Resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Database Message Resources" Watch "Database Message Resources" New topic

Database Message Resources

supriya pelluru

Joined: Mar 11, 2008
Posts: 4
Hi to all

In general we get the validation error messages in struts from message resources . But i want to get that error messages from database .For that , i want suggestions . please reply me .
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

supriya pelluru,
Welcome to JavaRanch.

Well, as far as *I* think, bringing error messages from database is not a good idea. Talking to databse requires heavy use of resources and an error situation in itself lead to resource locking (at times, not necessarily).

So, on the first *I* feel it would be a bad coding practice and moreover, a bad idea as well when we have message resource file.

But, somehow we we have a constraint to get the error messages from database then too the process goes the same way. Ideal practice will be to make your own exception handler which will fill the messages from database.
Once you get an error and reach the catch block. Just bundle that exception in your custom exception type and call your exception handler.

Another way(but, it's exhaustive) yet bad, is to get all mesasages from DB and store in some temporary session variable and use it appropriately.

Whatever be the case, *I* still feel weird about it and suggest to stick to message resource file.
I agree. Here's the link:
subject: Database Message Resources
It's not a secret anymore!