• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Sturts dataBase connection problem

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic