Hi,
I am trying to connect to a MySQL database through a Java Servlet. I
think I have correctly installed Tomcat 4.1.30 and the MySQL Database
along with ConnectorJ. I am getting a NumberFormatException at the
following piece of code:
Connection connection = null;
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mydatabase";
String username = "user";
String password = "password";
//exception gets thrown here
connection = DriverManager.getConnection(url, username,
password);
Here is the Exception thrown:
java.lang.NumberFormatException: For input string "localhost"
If I understand why a NumberFormatException is thrown, it is because
it is having trouble turning localhost into some sort of number. I've
tried various things like using my IP instead of localhost, getting
rid of the port and combinations of the like. I can successfully
connect to a MySQL database at my work using its web location. If
anyone could help shed some light on this problem, it would be greatly
appreciated.
thanks,
Joe