2009-11-16 195 views
-2

我的堆棧跟蹤:Java的MySQL連接錯誤

cbs.ui.OverallReportUI btnGenerateBillActionPerformed 
SEVERE: null 
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) 
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) 
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) 
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) 
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910) 
     at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923) 
     at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273) 
     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031) 
     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718) 
     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46) 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
     at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) 
     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302) 
     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) 
     at java.sql.DriverManager.getConnection(DriverManager.java:582) 
     at java.sql.DriverManager.getConnection(DriverManager.java:185) 
     at cbs.ui.OverallReportUI.GenerateReport(OverallReportUI.java:219) 
     at cbs.ui.OverallReportUI.btnGenerateBillActionPerformed(OverallReportUI.java:153) 
     at cbs.ui.OverallReportUI.access$100(OverallReportUI.java:38) 
     at cbs.ui.OverallReportUI$2.actionPerformed(OverallReportUI.java:85) 
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) 
     at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) 
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) 
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) 
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) 
     at java.awt.Component.processMouseEvent(Component.java:6038) 
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3260) 
     at java.awt.Component.processEvent(Component.java:5803) 
     at java.awt.Container.processEvent(Container.java:2058) 
     at java.awt.Component.dispatchEventImpl(Component.java:4410) 
     at java.awt.Container.dispatchEventImpl(Container.java:2116) 
     at java.awt.Component.dispatchEvent(Component.java:4240) 
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) 
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) 
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) 
     at java.awt.Container.dispatchEventImpl(Container.java:2102) 
     at java.awt.Window.dispatchEventImpl(Window.java:2429) 
     at java.awt.Component.dispatchEvent(Component.java:4240) 
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) 
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) 
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) 
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) 
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) 
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) 
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) 
+0

我建議不要使用根憑據進行數據庫訪問。您應該創建一個新用戶,該用戶只能由該應用程序用於數據庫訪問。 – Bobby 2009-11-16 08:32:59

+0

請發佈您的IP和root密碼,以便我們都可以幫助您解決這個問題! – Karl 2009-11-16 10:17:52

+0

-1。 – BalusC 2009-11-16 11:12:09

回答

7

中的關鍵文本看的是:

訪問被拒絕的用戶 '根' @ 'localhost' 的(使用密碼:YES)

這只是一個憑證問題。驗證您是否可以使用您的代碼所使用的相同憑據通過命令行進行登錄。