localhost - connection problem


I have a problem with java and PostgreSQL. When I type:

connection = DriverManager.getConnection("jdbc:postgresql://"+host+":"+postgresPort+"/thesis", user, password);

as long as the host equals "localhost" everything is ok. But when I type: "laptop" which is the real name of my machine (where in fact PostgreSQL is installed) it throws an SQLException.

I have a line: listen_addresses = '*' in my postgresql.conf file.

If someone could explain me that problem I would be grateful.

Thanks for any help