I have a web application which accesses MySQL using Hibernate as a JPA provider. Though all is well on my development rig, once I deploy the WAR to my server I get the following error:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Cannot open connection
The dev machine runs Ubuntu 10.10 and the server 10.04; both are using the provided MySQL package and Apache's (not Ubuntu's) tomcat6. I have more than triple-checked that the database is running, the credentials are correct and the driver is available.
I have this Resource definition in tomcat's context.xml:
<Resource name="jdbc/phenome_repository" auth="Container" type="javax.sql.DataSource" username="correctUserName" password="correctPassword" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/correctDatabaseName" />
Since the web application works locally, I believe its configuration to be correct (it has a resource-ref in its web.xml). As for MySQL, it is configured to listen on 127.0.0.1 and the "correctUser" above has all the necessary privileges (on localhost and 127.0.0.1).
Does anyone know any less usual causes of "Cannot open connection"?