It's not a secret anymore!
The moose likes Struts and the fly likes Sturts dataBase connection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Sturts dataBase connection problem" Watch "Sturts dataBase connection problem" New topic

Sturts dataBase connection problem

suhas Koley

Joined: May 24, 2007
Posts: 11
In the sturts-config.xml my code is :

<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName"
value="com.mysql.jdbc.Driver" />

<set-property property="url"
value="jdbc:mysql://" />
<set-property property="username"
value="root" />
<set-property property="password"
value="" />


in the action servlet i want to get the datasource using the method
DataSource dss = getDataSource(request);

It is showing the error :
Cannot resolve the symbol
method getDataSource(request);

I have put the sturts-lagency.jar into the lib folder but the thing does not change

Please help

PROFILE:<br />Suhas koley <br /><br />College:NIT(REC)Durgapur
Paras Jain
Ranch Hand

Joined: Feb 26, 2005
Posts: 138
The request object is of type ServletRequest or HttpServletRequest.

I doubt that it is of type ServletRequest if you are overriding
execute(ActionMapping mapping, ActionForm form,ServletRequest request, ServletResponse response)

instead of
execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)

Paras Jain
SCJP 5.0
suhas Koley

Joined: May 24, 2007
Posts: 11
Hi Paras ,

Here is my code

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

// If user pressed 'Cancel' button,

//Showing Error cannot resolve the symbol getDataSource(request)
DataSource dataSource = getDataSource(request);

catch(Exception e)

please check that
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3381

check you have the commons.jar included in your classpath.

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
suhas Koley

Joined: May 24, 2007
Posts: 11
I have added the following jar in the WEB_INF/lib of my application


The error exactly is:

Cannot resolve the symbol :method getDataSource(request)

Please help
I agree. Here's the link:
subject: Sturts dataBase connection problem
It's not a secret anymore!