I have imported the osm file into postgresql. The tables I have are planet_osm_ndes,planet_osm_ways, planet_osm_point. planet_osm_roads etc. But no table contains the information of neighbouring nodes of a node. I tried connecting to the database using java and tried finding the neighbours, but the code runs for hrs and still no output. Is there a easy way to do it

The osm2pgsql database schema is optimised for drawing maps; for this use case, neighbouring nodes are uninteresting. If you have used the --slim flag on osm2pgsql (which you apparently have since you mention planet_osm_nodes), you can look at the "nodes" array of ways in planet_osm_ways (step 1: find out which ways contain your node of interest, step 2: find out where in the node list your node occurs, step 3: find the nodes before and after, if applicable). However, it sounds as if your use case might warrant a different kind of database import that gives you easier access to the node/way connections, for example check out the "ApiDB" import offered by Osmosis.