learn java
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

Win a copy of The Software Craftsman this week in the Agile forum!
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: 9074

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]
Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: DataSource Problem