getConnection -> localhost is unknown!?
Posted by: Martin
Date: May 28, 2005 07:13PM

I have installed JDK 1.4.2, Connector 3.1.8a and when I load the driver everything's fine.
But when I try to connect to a database, it always says that it couldn't find the host. I have tried localhost, 127.0.0.1, my internal network IP, but i can't get a connection.

I don't think that this could really be a network problem, because everything else is ok. But I don't know. Perhaps somebody has experienced the same problem and could give me a little advice.

Here is my Java program:
I import java.sql.*

try {
// The newInstance() call is a work around for some
// broken Java implementations

Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception ex) {
// handle the error
System.out.println("EXCEPTION: " + ex.getMessage());
}

try {
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?user=root&password=mypass");
System.out.println("Got a Connection.");


conn.close();
}
catch (Exception ex) {
// handle the error
System.out.println("EXCEPTION: " + ex.getMessage());
}

Options: ReplyQuote


Subject
Written By
Posted
getConnection -> localhost is unknown!?
May 28, 2005 07:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.