我使用tomcat和mysql(IDE是eclipse)。 我正在使用連接池。mysql和javax.naming.NamingException
在context.xml中,我有:
<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" />
在我一直在使用中的EasyPHP MySQL的開始(用戶root沒有PWD)。一切正常。 然後我添加了pwd並正確更改了context.xml(就像現在這樣)。
從那時起,我有這些異常:
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)
的「奇怪」的事情是,應用程序在數據庫寫入成功。
我已經卸載了easyphp,並在端口3306上安裝了mysql,並使用pwd root創建了root用戶。
我獲得同樣的例外。
可能重複的[訪問拒絕用戶'root'@'localhost'(使用密碼:YES)(Mysql :: Error)](http://stackoverflow.com/questions/6081339/access-denied-for-user-rootlocalhost-using-password -yes-mysqlerror) – duffymo 2012-07-13 09:40:13
@duffymo:在這種情況下,重置pwd不會改變結果。儘管例外,應用程序訪問數據庫,寫在它上面。 – Sefran2 2012-07-13 10:01:55
如果您仍然遇到問題,請仔細查看Google的回覆。你不是第一個。 – duffymo 2012-07-13 13:09:49