Please try asking this question in the JDBC forum. What database are you using. SQL 2000 server has built in xml as response. Otherwise you may have to use JDBC to extract the data and build the XML by yourself.
prabhakar pullela, you have been asked before to refrain from posting the same question in more than one forum. Please stop doing it. Also, people will readily respond to a proper question but your current posts are only likely to get more questions as a response.