首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

struts与mysql数据源连接有关问题

2012-03-07 
struts与mysql数据源连接问题data-sourcesdata-sourcekey mysql type org.apache.struts.util.Gen

struts与mysql数据源连接问题
<data-sources>
<data-source   key= "mysql "   type= "org.apache.struts.util.GenericDataSource ">                                                                                                            
<set-property   property= "autoCommit "   value= "true "/>
<set-property   property= "driverClass "   value= "com.mysql.jdbc.Driver "/>
<set-property   property= "url "   value= "jdbc:mysql://127.0.0.1:3306/students "/>
<set-property   property= "maxCount "   value= "10 "/>
<set-property   property= "minCount "   value= "1 "/>
<set-property   property= "username "   value= "root "/>
<set-property   property= "password "   value= "admin "/>
</data-source>
</data-sources>
启动Tomcat6.0后出现以下异常:
信息:         createConnection()
2007-3-23   14:53:55   org.apache.struts.action.ActionServlet   initModuleDataSources
严重:   Initializing   application   data   source   mysql
java.sql.SQLException:   Access   denied   for   user   ' '@ 'localhost '   (using   password:   YES)
at   com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at   com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:771)
at   com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3649)
at   com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1176)
at   com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
at   com.mysql.jdbc.Connection. <init> (Connection.java:1485)
at   com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at   org.apache.struts.legacy.GenericDataSource.createConnection(GenericDataSource.java:805)
at   org.apache.struts.legacy.GenericDataSource.open(GenericDataSource.java:741)
at   org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1085)
at   org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at   javax.servlet.GenericServlet.init(GenericServlet.java:212)
at   org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at   org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at   org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
at   org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at   org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at   org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at   org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at   org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at   org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at   org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at   org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)


at   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at   org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at   org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at   org.apache.catalina.core.StandardService.start(StandardService.java:451)
at   org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at   org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native   Method)
at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at   java.lang.reflect.Method.invoke(Method.java:585)
at   org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at   org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2007-3-23   14:53:55   org.apache.catalina.core.ApplicationContext   log
信息:   Marking   servlet   action   as   unavailable
2007-3-23   14:53:55   org.apache.catalina.core.StandardContext   loadOnStartup
严重:   Servlet   /Students   threw   load()   exception
javax.servlet.UnavailableException:   Initializing   application   data   source   mysql
at   org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1091)
at   org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at   javax.servlet.GenericServlet.init(GenericServlet.java:212)
at   org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at   org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at   org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
at   org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at   org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at   org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at   org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at   org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at   org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at   org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at   org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at   org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at   org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at   org.apache.catalina.core.StandardService.start(StandardService.java:451)
at   org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at   org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native   Method)
at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at   java.lang.reflect.Method.invoke(Method.java:585)
at   org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)


at   org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
现在struts的连接池怎么也连不上,只能用jdbc来连接数据库,急!!!
请大家指教!

[解决办法]
Access denied for user ' '@ 'localhost ' (using password: YES)
通道拒绝为 user密码为空 用户名和密码的问题呀


[解决办法]
给你我的配置
<data-sources>
<data-source key= "org.apache.struts.action.DATA_SOURCE " type= "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource ">
<set-property property= "password " value= "imhrs " />
<set-property property= "minCount " value= "2 " />
<set-property property= "maxCount " value= "4 " />
<set-property property= "user " value= "imhrs " />
<set-property property= "driverClass " value= "com.mysql.jdbc.Driver " />
<set-property property= "description " value= "mysql coonection pool " />
<set-property property= "url " value= "jdbc:mysql://127.0.0.1:3306/imhrs?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8 " />
<set-property property= "readOnly " value= "false " />
<set-property property= "autoCommit " value= "true " />
<set-property property= "loginTimeout " value= "20000 " />
</data-source>
[解决办法]
我感觉也应该是user的问题,不过也不知道你的怎么写的,
[解决办法]
<set-property property= "driverClass " value= "com.mysql.jdbc.Driver " /> 

<set-property property= "driverClassName " value= "com.mysql.jdbc.Driver " /> 

1.2 和 2.0 有少许的差别
注意!!

热点排行