File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes DataSource Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DataSource Problem" Watch "DataSource Problem" New topic

DataSource Problem

Chan Apex

Joined: Oct 26, 2010
Posts: 16
I configured BasicDataSource in struts-config.xml file. when i'm accesing getDataSource(request) for DataSource object, it's giving error. I already added all jar files in lib folder. What is the problem? Please clear my doubt.
Thanks in advance.
Chan Apex

Joined: Oct 26, 2010
Posts: 16
I loaded classes12.jar, tomcat-dbcp.jar, and all struts .jar files.
javax.sql.DataSource dataSource;
java.sql.Connection myConnection=null;
try {
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();
Statement stmt=myConnection.createStatement();
catch(Exception e) {

giving the compile time error at getDataSource(request) method.
What is the problem??
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Chan Apex wrote:giving the compile time error at getDataSource(request) method.
Please post the error that you are getting

Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Chan Apex wrote:
dataSource = getDataSource(request);

This method is being invoked on the local class. Does your local class have an implementation of this method?
If you are counting on the Struts datasource functionality, it was deprecated long ago. See here for the preferred method for accessing a database.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: DataSource Problem
It's not a secret anymore!