Having reformatted my hard drive recently, I cannot get local Java / Tomcat / MySQL to work.
This is a clean MySQL installation, running on Mac OSX 10.7.3 (Lion).
The error I get is when my tomcat instance starts up and tries to connect:
SEVERE: Servlet /concorde-web threw load() exception java.sql.SQLException: Access denied for user 'concorde'@'localhost' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
Steps taken:
- I set the password
concorde@localhost as described here and here I can connect from the console using the same credentials. All the following works:
mysql -u concorde -h localhost -p mysql -u concorde -p mysql -u concorde -h localhost -D concorde -p // the app is trying to connect as user concorde to db concorde
I guaranteed that the Concorde user has rights - not only with localhost, but anywhere:
GRANT ALL ON concorde.* TO 'concorde'@'%'; FLUSH PRIVELEDGES;
What am I missing?
Also, what steps can I take to understand what is going on here? Are there any magazines I can check?
EDIT
As requested, here is the code I'm using.
However, this code worked fine before reformatting my hard drive, so I doubt that the problem is in it.
The application starts in the spring container, and during spring start, an overflow occurs.
Here are the relevant bean declarations:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="persistenceUnitName" value="spring-jpa" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="true" /> <property name="generateDdl" value="false" /> <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" /> </bean> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://${database.host}:${database.port}/${database.name}" /> <property name="username" value="${database.username}" /> <property name="password" value="${database.password}" /> <property name="initialSize" value="5" /> <property name="maxActive" value="50" /> </bean>
And here are certain properties:
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect database.name=concorde database.username=concorde database.password=password database.host=localhost database.port=3306
In addition, there is (abridged) permission request output:
mysql> select * from information_schema.user_privileges; | 'concorde'@'localhost' | def | USAGE | NO | | ''@'localhost' | def | USAGE | NO | | ''@'Marty-Pitts-MacBook-Pro.local' | def | USAGE | NO | | 'concorde'@'%' | def | USAGE | NO | +----------------------------------------+---------------+-------------------------+--------------+
Note. This was accomplished by logging in using root .
I suspect there is a hint in NO shown there for my user, but I'm not sure how to interpret this data.
mysql> select * from information_schema.SCHEMA_PRIVILEGES; +------------------------+---------------+--------------+-------------------------+--------------+ | GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE | +------------------------+---------------+--------------+-------------------------+--------------+ | 'concorde'@'localhost' | def | concorde | SELECT | YES | | 'concorde'@'localhost' | def | concorde | INSERT | YES | | 'concorde'@'localhost' | def | concorde | UPDATE | YES | | 'concorde'@'localhost' | def | concorde | DELETE | YES | | 'concorde'@'localhost' | def | concorde | CREATE | YES | | 'concorde'@'localhost' | def | concorde | DROP | YES | | 'concorde'@'localhost' | def | concorde | REFERENCES | YES | | 'concorde'@'localhost' | def | concorde | INDEX | YES | | 'concorde'@'localhost' | def | concorde | ALTER | YES | | 'concorde'@'localhost' | def | concorde | CREATE TEMPORARY TABLES | YES | | 'concorde'@'localhost' | def | concorde | LOCK TABLES | YES | | 'concorde'@'localhost' | def | concorde | EXECUTE | YES | | 'concorde'@'localhost' | def | concorde | CREATE VIEW | YES | | 'concorde'@'localhost' | def | concorde | SHOW VIEW | YES | | 'concorde'@'localhost' | def | concorde | CREATE ROUTINE | YES | | 'concorde'@'localhost' | def | concorde | ALTER ROUTINE | YES | | 'concorde'@'localhost' | def | concorde | EVENT | YES | | 'concorde'@'localhost' | def | concorde | TRIGGER | YES | | 'concorde'@'%' | def | concorde | SELECT | NO | | 'concorde'@'%' | def | concorde | INSERT | NO | | 'concorde'@'%' | def | concorde | UPDATE | NO | | 'concorde'@'%' | def | concorde | DELETE | NO | | 'concorde'@'%' | def | concorde | CREATE | NO | | 'concorde'@'%' | def | concorde | DROP | NO | | 'concorde'@'%' | def | concorde | REFERENCES | NO | | 'concorde'@'%' | def | concorde | INDEX | NO | | 'concorde'@'%' | def | concorde | ALTER | NO | | 'concorde'@'%' | def | concorde | CREATE TEMPORARY TABLES | NO | | 'concorde'@'%' | def | concorde | LOCK TABLES | NO | | 'concorde'@'%' | def | concorde | EXECUTE | NO | | 'concorde'@'%' | def | concorde | CREATE VIEW | NO | | 'concorde'@'%' | def | concorde | SHOW VIEW | NO | | 'concorde'@'%' | def | concorde | CREATE ROUTINE | NO | | 'concorde'@'%' | def | concorde | ALTER ROUTINE | NO | | 'concorde'@'%' | def | concorde | EVENT | NO | | 'concorde'@'%' | def | concorde | TRIGGER | NO |