Tomcat & MySQL Connection Problem

B

Bryan

Hello All,

I'm having some trouble connecting to a MySQL database from some Java
code I have running in Tomcat. I'm positive my credentials are correct
because I can access the DB using the command-line client. The DB is
on the same machine as the Tomcat server and is listening on the
default port. Tomcat is not running under a security manager. This
code works just fine on a development machine that's configured the
same, but when I move it over to my production machine I get a
CommunicationsException. I've added some output statements in my code
to see just how much goes on before I get the exception and it looks
like it happens the very first time I try to connect. I've read where
people usually get this exception after a connection has timed out,
but I don't think that's the case here. I've considered a DB
connection pool, but I'm not sure if that would help since it's
happening the very first time I try to connect. It even does it right
after I restart MySQL and Tomcat.

Any and all suggestions will be greatly appreciated!
 
N

Nigel Wade

Bryan said:
Hello All,

I'm having some trouble connecting to a MySQL database from some Java
code I have running in Tomcat. I'm positive my credentials are correct
because I can access the DB using the command-line client. The DB is
on the same machine as the Tomcat server and is listening on the
default port. Tomcat is not running under a security manager. This
code works just fine on a development machine that's configured the
same, but when I move it over to my production machine I get a
CommunicationsException. I've added some output statements in my code
to see just how much goes on before I get the exception and it looks
like it happens the very first time I try to connect. I've read where
people usually get this exception after a connection has timed out,
but I don't think that's the case here. I've considered a DB
connection pool, but I'm not sure if that would help since it's
happening the very first time I try to connect. It even does it right
after I restart MySQL and Tomcat.

Any and all suggestions will be greatly appreciated!

Provide more information.

What is the exception? Please post it verbatim, not a "something like"
explanation.

When you say that it works on a development system but not the production system
I presume you mean the same code in an identical environment on both systems?
Is the MySQL account you are using allowed to connect from the production
system - don't forget that MySQL accounts are host based, i.e you specify a
userid *and* host (which may be a wildcard). Do you connect to MySQL using the
FQDN or localhost? It makes a difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top