Hi Chitra, I don't know exactly what kind of application you're working on, but I can tell you how I connect to a database from my Flex front-end.
I use Flex's HttpService to call a URL, which then returns data sent from a Web Service. This Web Service can be written in Java, since you seem to have that knowledge. After using Java for ten years, I've switched to Ruby on Rails, which I find much more productive for database-backed Web Services. The data format I send back from my Web Services is XML, very easy to integrate into Flex components. Hope that helps, Chris.