Two Laptop Bag*
The moose likes Struts and the fly likes Datasource configuration in struts.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Datasource configuration in struts.xml" Watch "Datasource configuration in struts.xml" New topic
Author

Datasource configuration in struts.xml

Mariya Antony christopher
Ranch Hand

Joined: Jan 24, 2012
Posts: 49

In struts2 for database configuration in struts.xml not working ,Kindly suggest the comments
I have tried following database configuration steps
<data-sources>
<data-source key="pizza">
<set-property property="driverClass"
value="sun.jdbc.odbc.JdbcOdbcDriver" />
<set-property property="url"
value="Jdbc:Odbc:issuetracking" />
<set-property property="username" value="sa" />
<set-property property="password" value="sa" />
</data-source>
</data-sources>

public String execute() throws Exception
{
HttpServletRequest request;
DataSource ds = getDataSource(request, "pizza");
Connection con = ds.getConnection();
setMessage(getText(MESSAGE));
return SUCCESS;
}
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

We do not configure DataSource in struts.xml and we can do data source configuration using spring, hibernate Tomcat DataSource Configuration


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

As Mohana infers, datasource was removed from Struts after version 1.2.7.
Struts 2 is a very different framework from Struts 1.x (it is actually based on another framework, XWork). The fact that you are attempting to use datasource in Struts 2 makes me think you haven't worked much with Struts 2. Here is a summary of the differences.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
Don't get me started about those stupid light bulbs.
 
subject: Datasource configuration in struts.xml