Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

struts+database  RSS feed

 
Sanjay Deshpande
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following setting in struts-config.xml
<data-source
autoCommit="false"
description="Second Database Config"
driverClass="com.mysql.jdbc.Driver"
key="REFDB"
maxCount="4"
minCount="2"
password="password"
url="jdbc:mysql://localhost/sanjay"
user="sanjay"
/>
When i start tomcat i get following error:
8000 [main] ERROR action.ActionServlet - Initializing application data source database
java.sql.SQLException: Cannot load JDBC driver class 'null'
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529)
at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:381)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1039)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
at org.apache.catalina.core.StandardService.start(StandardService.java:497)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2190)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
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:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
8703 [main] INFO http11.Http11Protocol - Starting Coyote HTTP/1.1 on port 8080

Any solution ?
 
Tiago Fernandez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don' know why that's happening, but when I use DataSource in struts-config.xml, I do something like this:
<data-source key="MySQL-DS">
<set-property property="driverClass" value="org.gjt.mm.mysql.Driver" />
<set-property property="url" value="jdbc:mysql://localhost:3306/struts" />
<set-property property="maxCount" value="20" />
<set-property property="minCount" value="1" />
<set-property property="user" value="root" />
<set-property property="password" value="" />
</data-source>
Do you have the correct MySQL JAR file in your /WEB-INF/lib?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!