+2  A: 

I guess "www.localhost.com" should be simply "localhost"; this often happens if the server is not responding, Firefox attempts to search the server on the net. Are you sure the port number is correct?

NOTE#1: which appserver/webservice platform are you using? Did you write a client or are you trying to use the default automatically generated client?

NOTE#2: when your code will be invoked it will most likely throw a "null pointer exception" here

cityName.add(lastName);

because you forgot to initialize the list, and it may never find your city because you forgot to set the parameter

$cityName

before invoking the preparedStatement.

NOTE#3: you'd better test the web service invocation and the code it is executing in two different steps; consider writing a simple main or a test case for the latter.

Manrico Corazzi
I tried to change the port# as i have http://localhost:3306/TheLostNumberApplication/faces/welcomeJSF.jspbut it still doesn't work ...
3yoon af
A: 

I've experienced that before, but that was my DNS messing things up.

sshow
A: 

A few tips...

You should probably figure out where the error output from your program ends up. Typically, when running things in a servlet container (tomcat?) the server writes stdout and stderr to files (maybe in logs?) Also, find out how the application server/container logs exceptions.

Maybe you should try to run your code as a regular java application first.

When catching an exception, it's probably a good idea to use a logging framework to log the exception. Either log4j or java.util.logging will do.

...or - just for testing, do a exception.printStackTrace() so that you get the full information.

Also, the SQL query is'nt good... Look up PreparedStatement for dynamic parameters.


if( city_name == null ) {
  //return nothing?
} else {
PreparedStatement pstmt = con.prepareStatement("SELECT city_id, city_name FROM city WHERE city_name = ?");

   pstmt.setString(1, city_name); /// 

 ResultSet rs = stmt.executeQuery();
}
KarlP
A: 

As Manrico said; you are not connecting to you web server.

Change the url to "http://127.0.0.1:17978/LostNumApplication" and try again.

If that doesn't work it might be a firewall, or maybe the server is running on a different port.

If it's tomcat, check server.xml.

extraneon