Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database Message Resources

 
supriya pelluru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic