File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes configuring datasource in struts-config.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "configuring datasource in struts-config.xml" Watch "configuring datasource in struts-config.xml" New topic
Author

configuring datasource in struts-config.xml

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
Hi,
I am learning Struts and I want how to configure the data source in struts-config.xml. i.e., connection to a database. it can be either oracle / sql server. I am trying to add the username and password in the DB. (all the action, actionforms are ready). pls tell / sample site for configuring db in struts-config.xml
A knibbs
Ranch Hand

Joined: Aug 23, 2006
Posts: 158
Check out the reply that I got here in regard to database access - should prove useful to you.
http://www.coderanch.com/t/54917/Struts/Database-connection-method
Seetesh Hindlekar
Ranch Hand

Joined: Feb 13, 2004
Posts: 244
Hi,

struts-config.xml
=================

<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource" key="userDB">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="url" value="jdbc racle:thin:@112.118.5.28:1521 rcl" />
<set-property property="username" value="seet" />
<set-property property="password" value="seet" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery" value="SELECT COUNT(*) FROM emp" />
</data-source>
</data-sources>

Ensure that all jar files related to Oracle and the dbcp datasource are present in the lib folder so that the build.xml has the following entries.

<path id="compile.classpath">
<pathelement path ="lib/struts-legacy.jar"/>
<pathelement path ="lib/commons-dbcp-1.2.1.jar"/>
<pathelement path ="lib/commons-pool-1.3.jar"/>
<pathelement path ="lib/classes12.jar"/>
<pathelement path ="lib/ojdbc14.jar"/>
......
</path>

Rgds,

Seetesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: configuring datasource in struts-config.xml
 
Similar Threads
Readin struts-config.xml from Action
common-dbcp.jar
Regarding Struts ApplicationResource.properties
using forwarded url
Regarding values not clearing in the Form