This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Tomcat and MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat and MySQL" Watch "Tomcat and MySQL" New topic
Author

Tomcat and MySQL

Daniel Jackson
Greenhorn

Joined: Oct 16, 2008
Posts: 3
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

Joined: Jun 26, 2002
Posts: 860
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


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Daniel Jackson
Greenhorn

Joined: Oct 16, 2008
Posts: 3
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

"Bobby Islam" Please check your private messages for an important administrative matter.


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat and MySQL
 
Similar Threads
[Best practice] From Oracle to MySQL
Connecting to MySQL locally via JNDI
RMI marshalling arguments error
Is there a MySQL server running on the machine/port you are trying to connect to?
Connection Problem in Linux Server