Sethuraman.AR
Sethuraman.AR

Reputation: 125

Configure Data Source - Struts 1.3.8

how to configure data source in struts-config.xml in struyts 1.3.8 ?

My Sample Data Source:

<data-sources>
 <data-source type="org.apache.commons.dbcp.BasicDataSource" key="dbSource">
            <set-property property="driverClassName" value="com.mysql.jdbc.Driver" />
            <set-property property="url" value="jdbc:mysql://localhost:3306/bookstore" />
            <set-property property="username" value="root" />
            <set-property property="password" value="sf~007tech" />
  </data-source>
  </data-sources>

Code:

dataSource = (DataSource)servlet.getServletContext().getAttribute("dbSource");

Upvotes: 1

Views: 2480

Answers (1)

J&#246;rn Horstmann
J&#246;rn Horstmann

Reputation: 34014

It seems the data-sources element in struts-config.xml was deprecated and removed in struts 1.3, as detailed in the upgrade notes. I think it would be preferred to configure the datasource in the web container and do the look up through JNDI. Instructions can be found in the tomcat wiki.

Upvotes: 2

Related Questions