File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Storm Applied this week in the Other Open Source APIs forum!
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: 2533

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
youtube channel
I agree. Here's the link:
subject: Problem with localhost