This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat and MySQL

 
Daniel Jackson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Hopefully this is the right place to post this question.

I'm having difficulty getting my webapp connecting to the mysql server running locally.

If I write a simple Java application and do some sql through JDBC it works fine; connecting to, querying and receiving results from the database.

As soon as I try to do the same in a webapp thats deployed in tomcat (locally) I get the following error,

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

Why is this happening? I know all the connection parameters are correct. As far as I'm aware there's no firewall blocking or anything going on.

I'm using eclipse on Vista x64 with tomcat 6.0.18 with mysql 5.0.67 x64(if that helps).

I vaguely remember setting this all up on an xp box and it just working, so I'm guessing this might be a vista thing.

Any help would be appreciated, I seem to have hit a dead end on this one.

Regards,

Bobby
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using google? I found this by searching on the exception name. http://forums.mysql.com/read.php?39,181940,226710#msg-226710
 
Daniel Jackson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I have.

I've read several articles about this error occuring for slow queries and things to do with connection pooling.

My problem has nothing to do with those. It's a simple connect to database, run query, process resultset. Nothing fancy with threads or anything, very simple table as well. The webapp is very basic.

The article you linked to suggests Tomcat does connect to mySQL but loses it later on when the queries get slow. For me tomcat doesn't connect to mySQL at all, just throws the error I mentioned. But a standalone java app can use the database with no problems. My guess is tomcat is being silly somewhere, I just don't know where.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Bobby Islam" Please check your private messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic