0

I'm using tomcat and mysql (the ide is eclipse). I'm using the connection pool.

In the context.xml, I have:

 <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
          maxActive="100" maxIdle="30" maxWait="10000"
          username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/mydb" 
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" />

At the beginning I've been using the mysql in easyphp (the user root had no pwd). All worked. Then I've added the pwd and changed the context.xml properly (like it's now).

Since then, I've these exceptions:

Unexpected exception resolving reference
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

Failed to register in JMX: javax.naming.NamingException: Access denied for user    'root'@'localhost' (using password: NO)
lug 13, 2012 9:16:45 AM org.apache.naming.NamingContext lookup
Unexpected exception resolving reference
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

The "strange" thing is that the app succeeds in writing on db.

I've disinstalled easyphp and I install mysql on port 3306 creating the root user with pwd root.

I obtain the same exceptions.

Sefran2
  • 3,578
  • 13
  • 71
  • 106
  • possible duplicate of [Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)](http://stackoverflow.com/questions/6081339/access-denied-for-user-rootlocalhost-using-password-yes-mysqlerror) – duffymo Jul 13 '12 at 09:40
  • @duffymo: in this case, resetting the pwd doesn't change the result. And despite of the exceptions, the app accesses the db, writing on it. – Sefran2 Jul 13 '12 at 10:01
  • If you still have the problem, keeping digging through those Google responses. You aren't the first. – duffymo Jul 13 '12 at 13:09

1 Answers1

1

I would advise you to cut & paste the generic stuff in your error messages whenever you encounter a problem. At worst you'll be comforted to learn that you aren't alone or the first; at best you'll see an easy solution to your problem.

I pasted this

mysql java.sql.SQLException: Access denied for user 'root'@'localhost'

into a Google search and learned a lot of interesting things. So can you.

My other advice would be to create a separate username and password for your app and GRANT it appropriate permissions rather than using root. Root is powerful and should not be given out to applications, even if the app and database are both yours. Root has access to every table, including the system tables. I prefer to create a separate database for an app and GRANT an application username and password only those permissions that are needed to fulfill the mission (e.g. no DELETE permission unless needed; no DROP for tables, etc.)

duffymo
  • 305,152
  • 44
  • 369
  • 561