Well, it looks to me like your connection is being refused. A
connection refused usually means that there is nothing listening on the
port your trying to connect to. BTW: have you checked to make sure the
database is up and running?
You have provided very littler information about your setup, so it's
really hard to pindown an answer because there is no way for me to tell
which possibilities are in the ballpark and which are out in left
field. But I'll take a stab at guessing what the problem might be.
My wild guess is that your driver url is wrong. You say it ran fine in
an application version of your code, but did the url point to
"localhost" or did you declare the fully qualified hostname? In the
case is the former, are you executing your servlet on the same host as
you were the application? If you've specified "localhost" but now
you're running on a different machine than before, you'll need to
declare the fully qualified hostname in the url.
For example, let's assume that your original standalone application was
running on the machine "george.somewhere.com" and that you were
accessing a MySQL database running on host on foo as "localhost". But
also, let us assume that your servlet container, and thus your servlet,
is running on host "gracie.somewhere.com". If your driver url points
to "localhost" you will get a connection refused when your servlet
tries to connect to the database. The reason for that is that
localhost always resolves to address 127.0.0.1 which is an address that
refers to the machine on which you are currently running. Therefore, a
driver url pointing to localhost of gracie.somewhere.com will attempt
to connect to a database running on gracie.somewhere.com, and if there
is none, you'll get a connection refused. In order to access the
database which is actually running on "george.somewhere.com", you will
need to specify that hostname in the driver url, and not "localhost".
-- Rob
--On Monday, March 19, 2001 10:44:20 AM -0800 [EMAIL PROTECTED]
wrote:
> Hi
>
> I m trying to acces MySql database thru Servlets in Tomcat. But the
> same file runs in java public static void main application..
>
> The error is
>
> Unable to load driver.
> java.sql.SQLException: General Error: Connection refused: connect
> at org.gjt.mm.mysql.Connection.<init>(Connection.java)
> at org.gjt.mm.mysql.Driver.connect(Driver.java)
> at java.sql.DriverManager.getConnection
> (DriverManager.java:517)
> at java.sql.DriverManager.getConnection
> (DriverManager.java:199)
> at IDSTest2.doGet(IDSTest2.java:28)
> at javax.servlet.http.HttpServlet.service
> (HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service
> (HttpServlet.java:853)
>
> Please let me know wger I am going wrong..
>
> DINMAN
>
>
>
> Enjoy being an Indyan at http://www.indya.com
_ _ _ _ _ _ _ _ _ _
/\_\_\_\_\ /\_\ /\_\_\_\_\_\
/\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR
/\/_/_/_/_/ /\_\ /\/_/ /\/_/
/\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin
\/_/ \/_/ \/_/_/_/_/ \/_/ appears profound)
Rob Tanner
McMinnville, Oregon
[EMAIL PROTECTED]