jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Problem with localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem with localhost" Watch "Problem with localhost" New topic

Problem with localhost

Rose Rimsky

Joined: Feb 10, 2010
Posts: 25
Hi to all!! I'm working in a Java-Hibernate web project, but I am having a problem with my database connection. When I try to connect to it by writing localhost instead of my IP address, I can't connect to my db. The following error appears: java.sql.SQLException: I/O Exception: The Network Adapter could not establish the connection. Also, when I try to connect using the command telnet localhost 1521 the following error appears: Could not open connection to the host, on port 1521: Connection failed.
Why is this problem happening? How can I solve it?

I'm using Oracle 11g, any suggestion will be really appreaciated!
Thanks in advance

Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us that dragons can be beaten. – G.K. Chesterton
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

Hi Rose. That is not a problem with your code, but with the configuration of your computer.

If you are on windows, you can check in your computer has a localhost entry in its host file.
(on my xp installation, the host file is located at C:\WINDOWS\system32\drivers\etc)

The entry should look like this:

If the entry is there, or if adding the entry does not resolve your problem, you can contact your support team to help resolve it.

> tracert localhost (traceroute on linux and unix)
> ping localhost
will give your support team useful info.

Regards, Jan

OCUP UML fundamental and ITIL foundation
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem with localhost
jQuery in Action, 3rd edition