• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Database Connectivity with mySQL in struts 1.2.8

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai...

i m doing a web application in Struts...i m using struts 1.2.8, Tomcat 5.0 and MySQL Server version 4.1.18-nt...also using mysql-connector-java-3.1.12-bin.jar as JBBC connector...i copied the connector to Tomcat/common/lib diretory..i edited my struts-config.xml as follows........

<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property
property="driverClassName"
value="org.gjt.mm.mysql.Driver" />
<set-property
property="url"
value="jdbc:mysql://localhost:3306/javatest?autoReconnect=true" />
<set-property
property="username"
value="javauser" />
<set-property
property="password"
value="javadude" />
<set-property
property="maxActive"
value="100" />
<set-property
property="maxWait"
value="500000" />
<set-property
property="defaultAutoCommit"
value="false" />
<set-property
property="defaultReadOnly"
value="false" />
<set-property
property="validationQuery"
value="SELECT COUNT(*) FROM sharafnu_mail" />
</data-source>
</data-sources>

Still i can't run my application...i m getting this error...(in logs/localhost_log.2006-04-08.txt)-----------

2006-04-08 13:09:33 StandardContext[/VSupport]Servlet /VSupport threw load() exception
javax.servlet.UnavailableException: Initializing application data source org.apache.struts.action.DATA_SOURCE
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:812)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
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:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)


pls solve this...
thanks in advance...
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd strongly recommend you not use the Struts Datasource, mainly because of the following statement in the Struts documentation:


Struts DataSource manager should only be used with legacy business classes that don't provide their own connectivity. When possible, we strongly recommend use of the standard DAO pattern, so that the Action classes do not need to know anything about the persitence mechanism. The DataSource manager is being retained in Struts 1.x for backward compatibility but may not be retained in Struts 2.x or later.



My recommendation would be to follow the instructions in the Tomcat documentation for setting up a DataSource. They give a specific example for MySql. Then use JNDI to look up the datasource in your data access classes.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Struts forum.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic