Meaningless Drivel is fun!
The moose likes Tomcat and the fly likes tomcat - mysql : Connection refused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat - mysql : Connection refused" Watch "tomcat - mysql : Connection refused" New topic

tomcat - mysql : Connection refused

gianni ipez
Ranch Hand

Joined: Jan 02, 2007
Posts: 65
Hi all,
I am learning how to connect to mysql database through tomcat,
and I am experiencing a problem.
I have followed the instrunctions detailed in :
Apache Tomcat Faq Page
the problem is that invoking:

I get the page with output:
Foo Not Connected
Bar -1

and also the error in the log:

As someone told I checked the ports on my machine, and I have correctly set up mysql on port 3306, tomcat on 8080.
I have a firewall(Sunbelt Kerio), but I've already disabled it.

Any idea please?
Thank you in advance.
Juan Antonio Gomez Moriano

Joined: Oct 27, 2007
Posts: 3
Is your mysql server running?

Seems that the port is not open, you can quickly check if the 3306 port is open by doing a telnet to it :

telnet localhost 3306
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

I like doing a netstat -a on windows. Tells me what ports close to the one I want are open as well.

Shoot us the file that has your connection information and maybe we can see an error.

-Cameron McKenzie
gianni ipez
Ranch Hand

Joined: Jan 02, 2007
Posts: 65
Thank you for your answers.
if I check mysql in the services running I can get it.
It says started.

here are the answers at the prompt commands:
>telnet localhost 3306:

Connessione all'host perduta. (that means host connection lost)

when doing
>netstat -a:

Is there helpful?
Is this meaning something to you?
Thanks again!
Taslim Sohel

Joined: Jan 16, 2008
Posts: 1
I burned with the same problem for long time. I fixed that.
Just download the JTDS JDBC Driver and unpack it. Copy the file that you download from Sourceforge in to %TOMCAT_HOME%/common/lib.

That�s all. Restart your Tomcat and try again.

JTDS JDBC Driver Download Link:
I agree. Here's the link:
subject: tomcat - mysql : Connection refused
It's not a secret anymore!