Tomcat cannot find database
I installed a new mysql database on my new macbook. When deploying a WebDSL application I get the following exception, indicating that tomcat cannot connect to the database. I have probably seen this before, and I’m probably missing some piece of configuration, but forget which. (I have installed mysql 5.5 on Mac OS X Mountain Lion using the .dmg)
Asked by Eelco Visser on 24 March 2013 at 14:56
[14:49:52 yellowgrass] ERROR JDBCExceptionReporter:234 - Connections could not be acquired from the underlying database!
[14:49:52 yellowgrass] FATAL
java.lang.ExceptionInInitializerError
at utils.HibernateUtilConfigured.(HibernateUtilConfigured.java:91)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at utils.HibernateUtil.getSessionFactoryUsingReflection(HibernateUtil.java:28)
at utils.HibernateUtil.(HibernateUtil.java:23)
at utils.DispatchServlet.tryLoadGlobalsAndPerformInit(DispatchServlet.java:19)
at utils.DispatchServlet.init(DispatchServlet.java:38)
…
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
… 29 more
3 Answers
First thing to check is whether the configuration in application.ini is correct, for example:
dbserver=localhost dbuser=someuser dbpassword=somepassword dbname=webdsldb
Verify that you can log into mysql with the
Answered by Danny Groenewegen on 24 March 2013 at 15:17dbuser
(e.g.mysql -u someuser -p
), and that thedbname
database exists (show databases
).
Initially, I had not set the password for the
root
user that I was using inapplication.ini
. However, setting the password did not solve the problem. The database is issuing this warning:Answered by Eelco Visser on 24 March 2013 at 15:25
130324 15:19:02 [Warning] IP address ‘192.168.178.40’ could not be resolved: nodename nor servname provided, or not known
After restarting database and tomcat a couple of times the problem went away. Not really satisfactory.
Answered by Eelco Visser on 27 March 2013 at 11:08