permaculture playing cards*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DataSource Problem" Watch "DataSource Problem" New topic
Author

DataSource Problem

Chan Apex
Greenhorn

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
Greenhorn

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


A.A.Anbarasu
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
jQuery in Action, 2nd edition
 
subject: DataSource Problem