Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sturts dataBase connection problem

 
suhas Koley
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the sturts-config.xml my code is :

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

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


</data-source>


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
 
Paras Jain
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
suhas Koley
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paras ,

Here is my code

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

// If user pressed 'Cancel' button,
try
{

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





}
catch(Exception e)
{

}
please check that
suhas
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check you have the commons.jar included in your classpath.
 
suhas Koley
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added the following jar in the WEB_INF/lib of my application

commons-beanutil.jar
commons-beanutil1.6.jar
commons-beanutil1.7.0.jar
commons-chain-1.1.jar
commons-collection.jar
commons-dbcp.jar


The error exactly is:

Cannot resolve the symbol :method getDataSource(request)

Please help
suhas
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic